Code Red > AutoLISP (Vanilla / Visual)

Clearing Variables forcefully

(1/3) > >>

Binky:
Is there a way that I can get a variable that I created in a lisp routine out of memory while still inside the routine?  I ask this since I am having some difficulty with a routine I am writing.  I have the variable listed in the defun statement as a local variable.  as in I did this...

(defun c:whatever ( \ xyz)

Not being the most knowledgeable, but I believed that xyz would disappear once the routine ended successfully.  Turns out that it does not, I know this because I can type !xyz on the command line and get the list that I shoved in there.  That lingering information trips the routine when run a second time.

Guest:

--- Quote from: Binky on January 22, 2008, 10:45:37 AM ---Is there a way that I can get a variable that I created in a lisp routine out of memory while still inside the routine?  I ask this since I am having some difficulty with a routine I am writing.  I have the variable listed in the defun statement as a local variable.  as in I did this...

(defun c:whatever ( \ xyz)

Not being the most knowledgeable, but I believed that xyz would disappear once the routine ended successfully.  Turns out that it does not, I know this because I can type !xyz on the command line and get the list that I shoved in there.  That lingering information trips the routine when run a second time.

--- End quote ---

You've got your slash backwards.  It should be (defun c:whatever ( / xyz)

Didge:
Additionally, the forward slash in:  (defun c:whatever ( / xyz)
defines those variables as local to that particular function. Variables by the same name declared elsewhere, including the command line can contain other values.  Try experimenting with the following code:


--- Code: ---(defun c:TEST (/ x y z)
  (setq x 10 y 20 z 30)
  (list x y z)
)

(setq x 90 y 90 z 90)
(c:test)
(list x y z)

--- End code ---

TimSpangler:

--- Quote from: Binky on January 22, 2008, 10:45:37 AM ---Is there a way that I can get a variable that I created in a lisp routine out of memory while still inside the routine? 


--- End quote ---

(setq xyz nil)

MP:
Keep in mind that if variable xyz ever enjoyed global scope it will continue to exist as a global until it is explicitly deleted, even if myFunction (now) sports it as a local.

Navigation

[0] Message Index

[#] Next page

Go to full version