constrained_action(prog_tools) constrained_action(prog_tools)
NAME
constrained_action - just like an action but it checks
some constraints first
DESCRIPTION
The constrained_action class is actually a subclass of
logic that should look like an action. It allows one to
specify a list of constraints to be checked before executing its tick_actions. If a constraint fails then its
failed actions are executed. Each constraint has it's own
failed actions. If the failed action corrects the problem
then it should end with a object_name continue! message
to indicate that the problem has been resolved. Once all
the constraints have been satisfied then the tick_actions
are executed. Since this class is a child of logic all of
logic's methods can be used to test for conditions. See
example below.
SUPERCLASS
logic
INSTANCE VARIABLES
constraint_name
This is the name of the constraint currently being
sent commands. constraints= and failed_actions=
message will be setting this constraint.
value
In evaluating constraints and failed_actions the
scalar value must be set. A constraint should set
this value to 1 if it succeded and 0 if it failed.
A failed_action should set this value to 1 if it
was able to correct the problem that caused the
constraint to fail in the first place.
MESSAGES
constraint[=,+]actions
Set the actions for the constraint. Make sure these
actions set the instances value to 1 (TRUE) or 0
(FALSE).
continue!
Typically used in a failed_action to tell the constrained_action object that the failed constraint
has been taken care of. i.e. do not abort processing due to this failed constraint, it has been
taken care of.
failed_actions[=,+]actions
Set the actions to execute if the constraint is not
satisfied. These actions should set the instance
variable value to 1 if they have corrected the
problem.
new_constraint=name
Create a new constraint and set the current constrain name.
EXAMPLE
-- Create a simple constrained_action with only one constraint
-- creates a new constraint named need_popup_script
-- it checks to see if an action has been defined
-- if not then read in the script that contains the action
-- tell the constrained_action object to continue processing
-- if everything is ok then do the satisfied action
constrained_action new: simple_action
new_constraint=`need_popup_script'
constraint=`simple_action defined: popup_action;'
failed_actions=`<popup.scr'
failed_actions+`simple_action continue!;'
satisfied_actions=`popup_action do!;'
;
simple_action tick!;
SEE ALSO
logic action
Please send comments and suggestions toconsult@rpi.edu