In addition, the ctrl_op can be used to receive one or several control calls ("trigger modes") and react with sending one or several other control calls to its operands. The set of trigger modes has to be specified in the first (large) creation dialog entry, the set of response modes in the second entry. When the ctrl_op receives any of the trigger calls, it will react by applying all response calls to its operands. For convenience, all specifications can omit the initial NST_ part of the control call.
Unlike most other operator units, the ctrl_op can also act backward, i.e., have operands to its left (specify a negative position offset to reach them).
Example#1 illustrates
how the ctrl_op can be used to control a plot_xy unit in
various ways (first execute the for_op in order to add a few marker
points to the plot). As a remark, we mention that specifying the option
%H
or %h in the plot_xy creation dialog window will create the
plot_xy
with its window hidden initially. Similar as for the input_window unit,
a %h-hidden window will open on the first exec, while a %H
hidden window is "more firmly hidden": it will only open when a W_OPEN
control call is applied.
ctrl_opnd (NST_W_CLEAR,"foo");
will send the control call NST_W_CLEAR to the named unit "foo" (all NST control mode names are predefined variables in the prog_unit). Instead of the name string "foo", you also may supply an integer parameter to specify a relative position (e.g., 2 for the second successor, -1 for the immediate predecessor of the prog_unit, etc.).
Conversely, the prog_unit can also react to the control calls NST_INIT, NST_RESET,NST_CLEAR, NST_ADAPT and NST_EXEC (currently, it is restricted to these five). For each of them, there is a predefined jump label whose name is the part without the NST_, i.e, writing code such as
INIT: printf("response to NST_INIT!\n");
...
return;
RESET: printf("response to NST_RESET!\n");
...
return;
EXEC: // this is the default
...
return;
you can make the prog_unit execute different code portions for
each of the five above control modes (execution will start at the label
that pertains to the received control mode and then just continue to the
end or the first return statement encountered.
Example#2 illustrates
this with a left prog_unit that sends an NST_INIT call to
its successor, which is another prog_unit that also will react to
exec and adapt calls.