RDL2 Control Flow


RDL2 provides several control flow mechanisms to provide for conditional execution and looping.

if/then/else

The if/then/else provides simple conditional evaluations and is similar to the if/then/else constructs of most programming language. The basic syntax is:

if

expression

then

statements

else

statements

endif

select

The select construct provides for execution of one of several options. This is similar to the 'switch' statement in other procedural languages. The basic syntax is:

select

when

expression

then

statements

when

expression2

then

statements

otherwise

statements

end

The expressions are boolean expression and the statements for the first

when

statement are executed when the expression evaluates to true. If no

when

expression evaluates as true, the

otherwise

statements are executed. The

otherwise

clause is optional.

do until

The do until construct provides for simple looping. The basic syntax is:

do until

expression

statements

end

The statements within the do until loop are repetitively executed until the expression evaluates to true.

do while

The do while construct provides for simple looping. The basic syntax is:

do while

expression

statements

end

The statements within the do until loop are repetitively executed while the expression evaluates to true.

do (indexed)

The basic syntax is :

do identifier = start to end [by incr] statements end

The variable identifier is assigned the start value, and the contents of the loop are executed. At the end of the loop, incr is added to identifier. The loop will terminate when identifier is greater than end if incr is positive, or identifier is less than end if incr is negative. If by incr is omitted, then incr is 1.

Example 1:

do i = 1 to 10 by 2 log('mylog.log', 'i = ' + i) end

This will print:

i = 1

i = 3

i = 5

i = 7

i = 9

to the log file.

Example 2:

do i = 10 to 1 by -2 log('mylog.log', 'i = ' + i) end

This will print:

i = 10

i = 8

i = 6

i = 4

i = 2

trigger on

The trigger on control structure is used in rules and it must be the first executable statement within a rule. If the expression evaluates to true, the remainder of the rule is executed. If the expression evaluates to false, then the rest of the rule is ignored.

trigger onexpression

Functions

Functions, whether built-in or user written, may be called simply by name, with the parameters specified in parenthesis. For example, the following fragement creates a new message by calling the createMessage function, then sends the message to all connected viewers with the sendMessageToAllViewers function:

newmsg = createMessage('This is the message text') sendMessageToAllViewers(newmsg)

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*