defun
(defun symbol arguments term1 ...)
The defun function defines a function with a name specified by the symbol argument.
Arguments
symbol specifies the name of the function. Use the special prefix C: to define a new command. You can type the new command at the command prompt with its name, without parentheses.
arguments specifies a list of arguments. Local variables are separated from arguments with a single slash character (/).
term1 ... specifies one or more expressions to be evaluated.
Return Value
The defun function returns the name of the function being defined.
When the function is invoked, it returns the result of the last expression evaluated.
Sample Code |
Notes |
(defun MYFUNC (a b c)
(princ a)(terpri)
(princ b)(terpri)
(princ c)(terpri)
(princ)
) |
Function with three arguments
Examples :
(myfunc 1 2 3)
1
2
3
(myfunc 1 2)
1
2
nil
(myfunc 1 nil 3)
1
nil
3 |
(defun MYFUNC2 ( / a b) ...) |
Function without arguments and
two local variables |
(defun MYFUNC3 (a / b c) ... ) |
Function with one argument and
two local variables |
(defun MYFUNC4 () ... ) |
Function without arguments;
no local variables |
(defun C:MYCMD () ... ) |
Defines the command MYCMD
|
setq, load