Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Clear all the setq

4 REPLIES 4
Reply
Message 1 of 5
cadking2k5
1499 Views, 4 Replies

Clear all the setq

Is there a way to clear all the SETQ at the end of the command
4 REPLIES 4
Message 2 of 5
3wood
in reply to: cadking2k5

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.   

Message 3 of 5
Lee_Mac
in reply to: cadking2k5

Message 4 of 5
maalessi
in reply to: 3wood

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)

 

 

Message 5 of 5
scot-65
in reply to: 3wood


@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.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost