- (cond ((not blkname) (progn (princ "\nMissed.. Try again!")[color="red"](C:test)[/color]) ) ((not found) (princ "\n Block not found in drawing !!!") ) (t...
Having the cond relaunch the c:test command doesnt just relaunch the command, but relaunch it recursively! (hint 1: use a while... hint 2:Maybe you should read that thread made by a nice op called Grrrr who had the same approach before being suggested otherwise with a while example in the best reply he ever received...
Ah! I just understood the question... set a quote => set quote => (set(quote => setq.
Well, a for-each approach can be used for a list no matters the # of contained arguments. While (last ) retrieve the last element, you could also use (car ) to retrieve the 1rst element, or again the (nth ) to retrieve a specific element of the list (keeping in mind that the first element of a list is (nth 0 ). You could use (length ) to verify how many elements are contained in the list and act accordingly only if the length is 1.
..as for the quote function, won't be much use for you here. It just instructs cad to returns the expression without evaluating it, so (quote(princ "hello")) would literally return (PRINC "hello")
-------
The next part might be usefull to understand return values only if I correctly understood what you meant.
Are you reffering to the returned value of your function? If so, in your example, your users do not get the returned value. The returned value is the last expression evaluated, and the last thing you do is (princ), which exit quietly. Let's take these 2 functions.
- (defun foo ()(princ 2)(princ))(defun baz ()2)
By using them, here's what we get.
Even if it looks the same, let's bind their returned value to a symbol and see what happens
zzz doeesn't seems to contain anything, yet is doesn't return nil. If we check what is the type...
now lets check if zzz and (princ) are bound to the same object with the "nasty" (eq function
..so, any program ending by (princ) returns... (princ)
Cheers
(princ)