Good, good try!
Well kinda don't like as the HELP represents the cond functions. I think it rather should be:
(cond ((test-expr) [then-expr])) ...)
as then expression is optional. If it's omitted, then the result of test-expr is also the result of the condition. The cond function can have as many conditions as needed.
Important to remember:
- in LISP is every other value than NIL considered as True!!! Try: (and "Hello" True) or (and 1 True) even (and "" True) Minor exception is (and '() True).
- in LISP every function returns some value: (getpoint ...) (cond ...) (setq ...) (intiget)... all of them. Some functions return always nil, other always True. You need to see the HELP for that.
So back to our code. First, let's strip the code from all unnecessary stuff. Then see the commentaries and try/trace yourself:
(cond ((getpoint "Pick a point <dual>: "))
; if you pick a point, (getpoint) returns a list of coordinates, which is T for the condition and it's passed as result of the cond funtion
; if you right-click, (getpoint) return nil, which is result of the condition. Since the cond funtion does not have T yes, it goes for next condition
((initget 1))
; initget is processed, returns always nil - see HELP - so the condition is nil, cond contionues to next condition
((getpoint "Pick a point for dual: "))
; try right-click. Becouse of previous (initget) it's not allowed!!
; only option is pick a point, which will be passet as T for the condition as the result of the cond function.
)
See HERE how to TRACE the code, one expression after another. If you have any variables in the code (I haven't), click on it and hit the "Add watch button"...
Hope now you can your code get fixed.