Code Red > AutoLISP (Vanilla / Visual)

Vars function to find local variables

(1/1)

terrycadd:
I have been using Multi-Edit since my first programming job. It can be used to edit many different programming languages. However, it does not have the ability of tracking and showing your local variables. I wrote this function called Vars over a year ago, to help me get the list of required local variables in large AutoLISP programs. As you know after you add and delete parts of a long program your list of local variables may be incorrect and need to be revised. This function will also find variable names that you accidentally typed differently somewhere in the code, which as you know can be a headache to figure out why something isn't working as it should. Please check out the attached Vars function, and read the note and alert message in the top part code before running it.

Please let me know what you think, and if it's valuable for AutoLISP programmers.

TimSpangler:
Thanks Terry,

I use NotePad++ an it too does not have this ability.  I will be using it today.

terrycadd:
Tim,
I think you can substitute Notepad for another text editor such as Wordpad.
You just may need to provide the path if needed.

Here's a short function to demonstrate how to use the Vars function.
Select and copy the function below using Ctrl-C.
Run the Vars function and in the first Notepad window paste the code.

--- Code: ---(defun WordList (Str$ / List@ Num#)
  (while (setq Num# (vl-string-search " " Str$))
    (setq List@ (cons (substr Str$ 1 Num#) List@)
          Str$ (substr Str$ (+ Num# 2))
    );setq
  );while
  (reverse (cons Str$ List@))
);defun WordList
--- End code ---
Edit the first line to only include arguments and global variables.
Do not include the current list of local variables.

--- Code: ---Str$
  (while (setq Num# (vl-string-search " " Str$))
    (setq List@ (cons (substr Str$ 1 Num#) List@)
          Str$ (substr Str$ (+ Num# 2))
    );setq
  );while
  (reverse (cons Str$ List@))
);defun WordList
--- End code ---
Save and exit the first Notepad window.
The second Notepad window will open with the new list of local variables.

--- Code: ---List@ Num#
--- End code ---
Copy the new list of local variables and exit Notepad.
You may then paste the new list of local variables below the current list to compare the differences.

Adesu:
Hi Terry ,
Why not use with
Block your code or put your cursor at front of "(defun..bla..bla.."
hit "ctrl+A" key, then
Tools > check Selection and you would get as like this

[CHECKING TEXT <Untitled-1> loading... SELECTION]
.
; === Top statistic:
; Global variables: (ANG PT STR TH)
; Function definition (with number of arguments): ((C:TEST . 0))
; Check done.

Navigation

[0] Message Index

Go to full version