Hi, Steven

Originally Posted by
steven-g
No question, I am looking for hard critical assesment on any point, if I'm going down this path I really don't want to start with bad habits, so please be harsh if needed
First very important thing is to localise the variables you use, you probably know this as 'declaring variables' in VBA:
Code:
(defun C:visoff ( / ss1 )
(setq ss1 nil) ; <- you don't need this BTW
(setq ss1 (ssget))
(acet-ss-visible ss1 1)
)
What this means that when the routine finished with/without error the variables you localised are reset to nil.
Heres a more elaborated explanation by Lee Mac: Localising Variables
Second thing you probably know, that has to be done is to use some conditional functions like the if function:
Code:
(defun C:visoff ( / ss1 )
(if (setq ss1 (ssget))
(acet-ss-visible ss1 1)
); if
)
Although acet-ss-visible can handle null values, and does't crashes with error - overall its a good practice to make use of the conditionals.
Somewhere was written "never trust the user", which means theres always a chance to pass the wrong type of inputs.

Originally Posted by
steven-g
The hardest part is reading Lisp, is it now a command, a keyword, a variable or what? at least in Excel with VBA you get some color coding clues in the editor.
If you practice alot you'll get used to it, btw VLIDE's console gives enough hints:
Code:
_$ (type if)
SUBR
_$ (type (lambda (x) x))
USUBR
_$ (type "this is a string")
STR
_$ (type 1)
INT
_$ (type 1.)
REAL
_$ (type 'a)
SYM
_$ (type nil)
nil
Also try not to rely on the acet-* functions.
The best experience would be to practice here on the forum and post your codes, so you'll recieve advices/critics and build-up your skill.
You might find this thread kinda related,
and you can see how I learnt something new there thanks to Tharwat and LM (Now I feel that thread so old, like its been from 2012).
Bookmarks