You are almost correct. In your rectification above, the global variable will be set to nil if the user presses Enter without giving a distance.
The purpose of the cond function is to justify the default value that was previously stored. In my code snippet, the cond function will put in whatever value the user inputs (if the user actually does input something in). Otherwise, getdist then returns nil, and the cond function proceeds into the second line and inserts the default variable.
In your snippet, you managed to get your message prompt right. However, remember that, just because the prompt simply alerts the user the default value using <> doesn't mean that getdist acually returns that value. You still need to use if conditions to account for this.