Using the Check Command to Look for Syntax Errors

AutoCAD AutoLISP & Visual LISP

 
Using the Check Command to Look for Syntax Errors
 
 
 

You can perform additional syntax checking with the VLISP Check command. The Check command can detect the following errors:

  • Incorrect number of arguments supplied to a known function
  • Invalid variable name passed to a function (for example, a quoted symbol where a variable is required)
  • Incorrect syntax in special form function calls (for example, lambda, setq, and foreach)

Some syntax errors can only be determined at runtime and Check cannot detect these errors. For example, if you call a function that expects an integer argument and you supply a string, AutoLISP does not detect this until run-time. As a result, this error will not be detected until you run your program.

To run the Check command on text in an editor window

  1. Switch to the editor window containing the code you want to check.
  2. To check the entire file, choose Tools Check Text in Editor from the VLISP menu.

  3. To check the syntax of a selected piece of code instead of the whole program, choose Tools Check Selection.

VLISP displays error messages in a new Build Output window, if it detects errors. For example, if you change the iff in drawline-with-errors.lsp to if and run Check, the following error message results:

The message indicates that an if function call contains too many arguments.