The following grammar shows the basic building blocks of hoc programs
stmt: expr ; | select NAME; | access NAME; | generate NAME; | set_priority NUMBER; | dim NAME indexlist ; | variable = expr ; | procedure ( arglist ) ; | for( expr ; expr ; expr ) ; | while ( expr ) stmt ; | break; | continue; | if ( expr ) stmt ; | if ( expr ) stmt; else stmt ; | return optional-expr ; | { stmtlist } stmtlist: /* empty */ | stmtlist stmt indexlist: /* empty */ | indexlist index index: [ expr ]
Syntax and semantic of these control-structures are just like in
C
.
The select
statement has the special meaning discussed in the
previous chapter. It tells the YODA when to call this task, and
prepares the availability of the online data via the variable (or
array, depending on the selector database) NAME.
The access
statement is similar to the select
statement
in that it makes data available as an array. However, it does not
decide wether this task is called or not.
Quite special is the generate
statement. Here a subevent
(specified by its NAME in the selector database) is declared to be
generated by the callback. An array NAME and a variable NAME_LENGTH
holding the dimension given in the database are automatically
created.
The user then can change the contents of the array and the length of
the subevent which is actually written to the eventstream after the
analyze procedure has been called.
Closely related to this feature is the command set_priority
which allows to change the default priority of 50 to any value in the range
1-99. A lower number means that the callback is called earlier. This
allows to create subevents by one callback whcih can then be selected
or accessed by callbacks (soft or hard) of higher priority.
The priority of a soft callback cannot be changed via a task
reload. The task must be unloaded and then loaded again in order to
make the new priority active.
Variables need not to be declared. All variables are of type
double
and are global (i.e. every function or procedure of the
same task can access the variable for reading and writing).
To define simple arrays (of type double
, as all variables are),
use the dim
statement. It defines the following NAME to be an
array with the dimension expr
. Note that arrays are indexed
just as in C
, starting with zero with the last valid index is
dimension-1. Note also that whole arrays cannot be passed to procedures
or functions.
YODA also supports multidimensional arrays. They are declared like
dim x[10][5]
.