Thanks all for the insight. I still don't know why it won't return a value when rValue is nil.
OK, going over the code again ... it would have been simple if you listed the error code as I asked in my 1st post on this thread:
You'll note that your code isn't initializing the rValue variable in all cases. So if the dialog isn't visible then rValue = nil. Then the 1st test in the cond is using the strcase function. This will error if the argument contains anything but a string. So it errors because the value inside rValue is nil and not a string. Therefore once it reaches the first strcase call, the entire defun errors out - with something like:
bad argument type: stringp nil
There are various ways you could go about fixing it:
- Initialize rValue to the empty string "" (or any string whatsoever except one of the 3 options) at the same place you're initializing nValue (i.e. before the if, though anywhere in the defun's root scope before the cond would also suffice)
- Set rValue in the else portion if the if (again empty or anything but the options). Similar to your last post
- Add a condition in the cond before any of the strcase's which tests if the value inside rValue is a string. E.g. using (= (type rValue) 'STR); OR
- Add a condition in the cond before any of the strcase's which tests if the value inside rValue not nil. E.g. using (not (null rValue))
There might be other solutions also, but these are some I thought of.[/list]