(defun [c:] name ([arg1 arg2 ...] / [local-var1 local-var2 ...]) expression)


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:

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 Bricscad. This makes it look like any other Bricscad 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 Bricscad to treat the LISP function like a Bricscad 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...

(ads)

(atoms-family format [symbol1 symbol2 ...])

(command cmd [arguments] ...)

(menucmd string)

LISP Compatibility

Programming Overview of LISP (LISt Processing) Language

 


Bricscad™ is commercialized by Bricsys NV. Bricsys NV and Vondle NV are fully owned subsidiaries of Menhirs NV. © 2001- Menhirs NV - All rights reserved.