- (if (not Curv:def) (setq Curv:def "Spline"))
If that makes things simpler. - However I like the use of or as it makes the code more concise.
The way to think about it is that or keeps evaluating statements until a statement returns T, at which point it stops evaluating. Hence, if Curv:def has a value, then it is non-nil (remember that T is anything non-nil), and hence the (setq... will not be evaluated. And vice-versa.
If you look at the Visual LISP Editor help file on the wcmatch function, it is used to match a pattern within a string - hence I am using it to suppress the "cancelled" messages. If the error message does not contain the phrases listed, then it will be printed, else not.
vl is just a list of Strings. in this case the strings are the names of our System Variables.
mapcar will execute the provided function (in this case getvar) on every item in the list, and return a list of the results.
Hence, if the CMDECHO was 1, an OSMODE was 55, ov would be set to something like:
Depending on the values of the System Variables listed.
Ok, the or has nothing to do with the initget function. The initget function is set to allow the keywords listed, and also allows the user to hit enter - which would make the getkword return nil.
Hence, using the logic described above:
Either:
1) the getkword returns nil, hence the not getkword returns T - and so the second statement is not evaluated, so the Current value of Curv:def is used in the following statements.
Or:
2) The getkword returns a non-nil value - and so the user has typed something, so the second statement will be evaluated, and so the value of curv:def will be set to this new input.
progn is used to "wrap" expressions so that they are treated as a single expression.
IF would normally require three (or fewer) expressions:
- a test expression
- "then" expression
- "else" expression
And so, we use progn to wrap all the expressions that we want evaluated if the test expression returns t. So that the if statement treats them all as one expression.
If the progn was not used, only the next expression would be evaluated, and then an error would ensue saying too many arguments.
This, as I said, could be done differently, using the "layer" option in the "offset" command.
Hope this helps,
If you still don't understand something that I have written, just ask.
Lee