<<<<<<<<<<<<<<<<<

actions(prog_tools) Programming Tools actions(prog_tools)

NAME

actions - a group of LYMB statements that can be executed when needed

DESCRIPTION

The object actions is a class that can be used to store LYMB statements and execute them when needed. Instances of actions are generally used in conjunction with user interface, logic, loop, scene and/or cue objects to perform operations in response to particular events.

As a convenience to the user, LYMB statements can be gathered into logical groups using the message tick_actions+ to specify each group. When actions is invoked using the tick! message, each group is sent to the parser separately. By using the break! message, the processing of actions can be stopped between groups of LYMB statements.

SUPERCLASS

object

INSTANCE VARIABLES

tick_actions is a list of LYMB statements. (Logically separate groups of statements may be created by using the

MESSAGES

assume_static_objects_on! Turns on the "assume_static_objects" mode. When this mode is on, and when compile mode is on, the actions object maintains object pointers for all objects referenced in the tick_actions, and method pointers for all messages. This eliminates the overhead associated with looking up identifiers in the object table, and also the overhead of doing msg_sends. (msg_connects are done instead. If the msg_connect returns SUPERCLASS_RESPONSIBILITY, the actions object handles the propagation correctly itself.) This mode will not work in situations where identifiers do not refer to the same underlying object from one invocation to the next, for example, when an object named in the action is freed and then re-created (as an instance of either the same or a different class). This is usually safe to use for most typical uses of actions objects. It is NEVER safe to use in the actions object associated with a procedure object, and therefore the procedure object does not understand these messages. This is because the procedure object re-instantiates its formal parameters on each call.

assume_static_objects_off! Turns off the "assume_static_objects" mode.

compile_on! Turn on compile mode. When compile mode is on, the parser is used only to compile the tick actions and send "tokens" back to the actions object which maintains the compiled actions internally. Actions are compiled only when a "tick!" or "do!" message is sent, and only if the tick_actions have been modified since the last time a compilation was done.

compile_off! Turn off compile mode. At each "tick!" message, the parser is used to parse and execute the actions. If a syntax error occurs during compilation, this message is automatically issued to ensure that the actions object does not attempt to execute a partially generated token sequence.

tick! invoke the LYMB statements contained in the instance variable tick_actions. Each group of LYMB statements is processed separately.

do! same as the "tick!" action.

tick_actions= LYMB statements set the tick actions. Any previously set actions are discarded.

tick_actions+ LYMB statements add to the list of tick actions. The group of LYMB statements provided to this message will be parsed separately from any other LYMB statements.

tick_actions? Print the tick actions.

break! stop parsing the actions block after completion of the current group of LYMB staments.

EXAMPLE

The first example shows how to create an actions object that will print itself.

/* * Create an actions instance that prints itself */ actions new: action_1 tick_actions=( "! print myself", "action_1 print!;" ) ;

/* Now we can use tick! or do! to run the action. */

action_1 do!;

The second example shows how to use actions in conjunction with the logic object to stop processing the actions. Very useful for error processing.

/* * Create an actions to check string for correct value. If not * correct, action aborts. Runs inconjuntion with logic and string * instances. */ logic new: if;

string new: null="";

actions new: print_string tick_actions= `if equal: (null,astring) true: `print_string break!;'; ' tick_actions+ ( `! This is the string', `astring print:value;' ) ;

string new: astring=""; print_string tick!; -- shouldn't print

astring = `Hello world'; -- should print print_string tick!;

SEE ALSO

logic loop scene cue ui motif


Please send comments and suggestions to
consult@rpi.edu