Two examples show simple usage. These examples are in src/scheduler.cpp.
There are a few ways to specify an expression to be parsed.
- new EvExpr(marsym, Ex("x << 3","'hello' + x >> Stream.opn"),Rp("false"));
specifies a primary expression within the Ex constructor that is
to be executed on every repetition of the event. Values to be used
in the expression may be initialised in the first string, then
used in the second string. The first string is evaluated as soon
as the expression event is posted on some timer. The second string
is executed on each repetition. The init string is optional within
the Ex constructor (in fact the Rp exprsession may also have an
init expression though it can be combined with the ExInit
expression). However the expression inside the Rp Constructor
specifies a repeat expression that determines if the event is to
be repeated. This expression must have a type boolean.
- new EvExpr(marsym, ExFile("filename.expr"));
the expressions for Ex and Rp can be read in from a file. This
eliminates the need to recompile each time an expression needs to
be adjusted. The file format is text where the lines expected by
Ex and Rp are separated by titles:
- #ExInit: - specify an init variables expression.
- #ExExpr: - specify the expression to be repeated.
- #RpInit: - specify an init variables expression for the repeated expression. The repeat expression may share variables with the primary Ex expression so anything specified here can be specified in #ExInit:
- #RpExpr: - specify a boolean expression that determines if the expression event is to be repeated after each repetition. This expression is evaluated after the primary expression.
- #RpRate: - (Not implemented yet, pending) specify an expression that evalutes to a mrs_string that determines how far into the future the event is to be posted after it is evaluated. The result must have meaning in the current timer timebase.