Table of Contents

Class LispInterpreter

Namespace
OpenCAD2D.Lisp
Assembly
OpenCAD2D.Core.dll

The functions only AutoCAD can run: ObjectARX, the Visual LISP compiler and projects, AutoCAD's command table and registry, its debugger and editor. They are defined, so that a routine written for AutoCAD finds the name, and calling one is an error that says so, ARXLOAD is not available: ObjectARX applications load only in AutoCAD., which vl-catch-all-apply catches like any other. Where AutoCAD names a value for a failed load ((arxload "app" nil)), that value is given, as it is when AutoCAD cannot load the application. Which of them exist before (vl-load-com) was measured in AutoCAD 2021 (probe g8): all but the registration and product keys of ActiveX.

public sealed class LispInterpreter
Inheritance
LispInterpreter
Inherited Members

Remarks

Each document has an interpreter of its own, and nothing it defines is seen by another. Each call of Run(string), RunCommand(string) or Load(string, object) is evaluated on a new background thread with a stack of 256 MB while the caller waits, so that a routine that recurses deeply cannot take the host down: user functions nested past 20 000 deep give the hard error internal stack limit reached (simulated), which neither *error* nor vl-catch-all-apply sees. The two threads never run together: the evaluating thread hands the caller's thread whatever touches a document, and a routine that waits for the user (the get functions of a CadCommandSession) gives control back to the caller until it is answered. A call made while an evaluation goes on or waits is refused with Can't reenter LISP..

A function of a later stage (command, ssget, vla-, vlax-) is not defined, and calling it gives no function definition: NAME, as AutoCAD does for a function it does not have.

Constructors

LispInterpreter()

Makes an interpreter with the functions of the core language and nothing defined by a program.

Properties

CommandNames

The names of the commands the program defined, without C:, sorted by ordinal comparison.

LoadedFiles

Gets the files this interpreter has loaded, as full paths in the order they were first loaded: the files of Load(string, object) and of (load) that were read to their end, which includes the startup files and what one file loads from another. A file whose load failed, from a missing file to an error inside it, is not in the list, and a file loaded twice is listed once. Empty until a file has been loaded.

RegistryFile

Gets or sets the file vl-registry-read, vl-registry-write, vl-registry-delete and vl-registry-descendents keep their keys and values in: the presenter keeps a store of its own rather than writing the Windows registry. Interpreters given the same file share the values. Null, the default, keeps them in memory for this interpreter alone.

SupportFolders

The folders load searches for a file given without a folder, in order: the support file search path. Empty by default, and null is taken as empty. The folder of the drawing is not searched, as in AutoCAD.

Variable

Reads a setting of the drawing by its name (LUNITS, LUPREC, AUNITS, AUPREC, DIMZIN), the way rtos and angtos take their defaults. When it is null, or gives null for a name, the defaults of a blank drawing apply: 2, 4, 0, 0 and 0.

Methods

GetValue(string)

Gets the value of a symbol.

IsCommand(string)

Tells whether C:NAME is a command: bound by defun or defun-q, which a setq of a lambda to c:name is not.

Load(string, object)

Loads a file as (load path) does: a rooted name is that file, any other (a bare name, or one with a relative folder such as Sub/x or ./x.lsp) is looked for in the SupportFolders in order, and .lsp is added to a name with no extension. The forms are read and evaluated one at a time, so an error leaves what ran before it.

OpenParens(string, out bool)

Counts the parentheses still open in text typed so far, to tell the command line whether to wait for more with its (_> prompt. Parentheses in strings and comments are not counted.

Print(object, bool)

Writes a value as prin1 (quoted) or princ does.

Read(string)

Reads the first form of the text, as (read text) does.

Run(string)

Reads and evaluates every form of the text, one after the other, and stops at the first error.

RunCommand(string)

Runs the command C:NAME with no arguments, as the command line does when its name is typed. A function that takes arguments gives too few arguments.

SetValue(string, object)

Sets the value of a symbol, making the symbol if there is none of that name.