Action Expressions

AutoCAD AutoLISP & Visual LISP

 
Action Expressions
 
 
 

An action expression can access the variables shown in the following table, indicate which tile was selected, and describe the tile's state at the time of the action. The variable names are reserved. Their values are read-only and have no meaning, unless they are accessed within an action expression.

Action expression variables

Variable

Description

$key

The key attribute of the tile that was selected.

This variable applies to all actions.

$value

The string form of the current value of the tile, such as the string from an edit box, or a "1" or "0" from a toggle.

This variable applies to all actions.

If the tile is a list box (or pop-up list) and no item is selected, the $value variable will be nil.

$data

The application-managed data (if any) that was set just after new_dialog time by means of client_data_tile.

This variable applies to all actions, but $data has no meaning unless your application has already initialized it by calling client_data_tile. See Application-Specific Data.

$reason

The reason code that indicates which user action triggered the action. Used with edit_box, list_box, image_button, and slider tiles.

This variable indicates why the action occurred. Its value is set for any kind of action, but you need to inspect it only when the action is associated with an edit_box, list_box, image_button, or slider tile. See Callback Reasons in the following section for details.

If edit1 is a text box, the action expression in the following action_tile call is evaluated when the user exits the text box:

(action_tile "edit1" "(setq ns $value)")

The $value contains the string that the user entered, and the expression saves this in the ns variable.

The next example saves the name of the selected tile so that the program can refer to it:

(action_tile "edit1" "(setq newtile $key)")

The newtile variable is set to the key name of the selected tile, in this case "edit1". The $key variable is very useful within a function that serves as the action for several separate tiles.

When a tile is named in more than one action_tile call, only the last such call (prior to start_dialog) has any effect. (It's as if you were to assign multiple values to the same variable.) The programmable dialog box (PDB) feature allows only one action per tile.