Connect CDC Director complex expressions consist of a combination of programming statements that produces a return value, which may be Boolean.
The supported programming statements are compliant with the Java or C grammar for these statements, except as noted in the Expression Handler appendix in the Connect CDC Director System Reference.
Basic rules for complex expressions:
-
The first statement must be a “begin” statement (for an unnamed expression) or a “procedure” statement (for a named expression, or procedure).
-
The last statement must be an “end;” statement.
-
Statements must be terminated with a semi-colon (;).
-
Use uppercase or lowercase but not mixed case for statement names and other reserved words.
-
Blocks, or multiple statements grouped within left and right braces ({. . .}), may be specified anywhere a single statement can be used.
The following listing provides descriptions of the individual supported statements:
Statement |
Description |
BEGIN RETURNS type; |
Denotes the start of an expression. See Expression data types. |
END; |
Denotes the end of an expression. |
DECLARE type var; |
Starts a section that contains the definitions of variables and other items such as constants and cursors. |
FOR (init; test; incr){ }; |
Executes a command to iterate over a range of values. The general form of the for statement can be expressed like this: for (initialization; termination; increment){statement} The initialization expression initializes the loop. It is executed once at the beginning of the loop. The termination expression determines when to terminate the loop. This expression is evaluated at the top of each iteration of the loop. When the expression evaluates to false, the loop terminates. Finally, increment is an expression that gets invoked after each iteration through the loop. All these components are optional. In fact, to write an infinite loop, you omit all three expressions. |
WHILE ( ){ }; |
Executes a command while a specified condition is true. |
DO ( ) { }; |
Executes a command to evaluate the expression at the bottom of a loop instead of at the top. Thus the statements associated with a do are executed at least once. |
IF ( ) { } ELSE ( ) { }; |
Executes a command only if a specific condition is met; otherwise, executes another command. |
SWITCH ( ) { }; |
Evaluates a variable that can later be matched with a value specified by the CASE keyword in order to execute a group of statements. |
CASE val; |
Defines a group of statements to begin executing if a value specified matches the value defined by a preceding SWITCH keyword. |
DEFAULT; |
Optionally used after all CASE conditions in a SWITCH statement. If all CASE conditions are not matched by the value of the SWITCH variable, the DEFAULT keyword will be executed. |
BREAK; |
Forces an immediate exit from a loop. |
RETURN val; |
Executes a command to exit from the current method. The flow of control returns to the statement that follows the original method call. The RETURN statement has two forms: one that returns a value and one that doesn't. To return a value, put the value (or an expression that calculates the value) after the return keyword: return ++count; The datatype of the value returned by RETURN must match the type of the method's declared return value. When a method is declared void, use the form of return that does not return a value: return; |