It is defined at beginning.
Just write down all symbol names in the bracket of DEFUN, after the slash, with at least one space between slash and the first variable.
Example:
(defun C:test (/ s1 s2 s3)
(setq s1 "Loquat"
s2 "Lychee"
s3 "Longan“
s4 "Persimmon"
)
)
s1, s2 & s3 are set to nil because they are local varialbes and will be set free when the expression completed.
But s4 is still in current drawing session because it is not in the variable list of the DEFUN function.
These tutorials may be of interest:
I use this to find the global variables I do not want as globals, I put it as it is if you have any doubt, ask.
(setq *TempLeak* nil) ; wipe on (re)loads ; ; original by R. Robert Bell, MCSE ; (defun C:ALE_Leak (/ lVars orgAtoms) (cond ( *TempLeak* (setq orgAtoms *TempLeak*) (princ "\nRicerca atomi non-localizzati...") (foreach atomVar (atoms-family 1) (ALE_FUZZY nil) (cond ( (member atomVar orgAtoms) (setq orgAtoms (vl-remove atomVar orgAtoms)) ) ( (wcmatch atomVar (strcat "`#*,C:*,ALE_*,MSW_*,MSX_*,ADI_*,ADA_*,MSXP-*,MSXM-*,MSXC-*,DDP_*,DDBEAM_*," "ALD_*,DVAR_*,*DWGVAR*,SCRMKR*,3DS_*,VLA-*,VLAX-*,:VLR-*,VLR-*,DBASE_*" ) ; usare le maiuscole in wcmatch ) ) ( (setq lVars (cons atomVar lVars)) ) ) ) (princ " fatto.\nAtomi non-localizzati: ") (if lVars (foreach atomVar lVars (princ (strcat atomVar " ")) ) (princ "nessun atomo trovato.") ) ) (T (princ "\nInizializza la lista degli atomi... ") (setq *TempLeak* (append '("*TEMPLEAK*" "ORGATOMS" "#SPIN" "*LAST-VALUE*") (atoms-family 1) ) ) (princ " fatto.") ) ) (princ) ) (princ)
@3wood wrote:
But s4 is still in current drawing session because it is not in the variable list of the DEFUN function.
I call these Gremlins.
If you need to remember the variables for the current session only, this is allowed.
However there might be conflicts down the road unless these gremlin names are
unique. For instance, I prefix my gremlins with "USER_". The suffix is the program's
name.
USER_test
AKA: "Remember settings from last use", especially when using dialogs or keyboard answers.
???
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.