Create a LISP function.
When you write a LISP file, the file itself is not actually the function. Rather, one LISP file contains one or more functions (or programs) that are all available when the file is loaded with the load function.
The name of a function must be defined in the first statement using the defun function. This function is the first actual command within the program. It begins with an open parenthesis, which closes at the end of the program.
The defun function is followed by the name of your function or program. Once a name is selected, you have a few choices:
(defun newfunc ( )
...
)
(defun newfunc ( / N)
...
)
(defun newfunc (A / N)
...
)
Once your function is defined with all its variables, you can choose to use the C: option. Prefixing the C: to the function name enables the command name to be entered without parenthesis at the command prompt of IntelliCAD. This makes it look like any other IntelliCAD command such as Line, Arc, and Circle.
(defun C:newfunc ( A / N)
...
)
NOTE The C: has nothing to do with your computer's C: drive. In LISP, it is short for "command" and tells IntelliCAD® 2001 to treat the LISP function like an IntelliCAD command.
Following the lists of variables, the expression that will make up the body of the program must be entered before the closing parenthesis.
Examples
Code | Results: |
---|---|
(defun newfunc ( ) . . .) | May use global variables. |
(defun newfunc (var1 var2). . . ) | Newfunc receives two outside values. |
(defun newfunc (/ var1 var2). . .) | Newfunc has two local variables. |
Tell me about...