JimYuan's Blog

Sharing the things I learned

0%

UsingVisualLISPDebuggingTools

Differentiating Between Local and Global Variable

  • Global variables are accessible by all functions loaded within a document(or drawing).
  • Local variables retain their value only as long as the function that defined them is running. After the function finishes running, the local variable values are automatically discarded, and the system reclaims the memory space the variable used.

Using Local Variable in the Program

1
2
3
4
5
6
7
8
9
(defun gp:getPointInput	(/ StartPt EndPt HalfWidth)
(if (setq StartPt (getpoint "\nStart point of path: "))
(if (setq EndPt (getpoint StartPt "\nEndpoint of path: "))
(if (setq HalfWidth (getdist EndPt "\nhalf-width of path: "))
T
)
)
)
)

The local variables are declared following the slash character.