Constant Expressions

A constant expression is a combination of basic elements with values that can be determined at compile time. These basic elements can be Boolean constants, integer constants, real constants, string constants, or job parameters that appeared in the job parameter list.

The constant expressions allowed by WFL are a subset of the various types of expressions that have been described earlier in this section. For example, Boolean constant expressions are a subset of Boolean expressions. The difference is that variables are not allowed in constant expressions.

A constant expression can be used anywhere an expression of the same type is allowed. Constant expressions can also be assigned as values in variable declarations, where expressions that use variables are not permitted.

The following pages give the formal syntax of Boolean constant expressions, integer constant expressions, real constant expressions, and string constant expressions.

Example

The following example illustrates constant expressions:

?BEGIN JOB PARAMPASS (BOOLEAN TF1, INTEGER X, STRING S);
  BOOLEAN BOOL1:= NOT TF1; % Boolean declaration
  INTEGER INT1:= X * 2; % Integer declaration
  RUN (DEVA)OBJECT/POOCH(BOOL1,INT1);
  RUN (NATTY)OBJECT/FREE(TAKE(S,2));
?END JOB.

The Boolean declaration in this example uses a Boolean constant expression to initialize the variable. TF1 is a Boolean constant identifier that was passed in as a job parameter. The integer declaration uses an integer constant expression. X is an integer constant identifier that was passed in as a job parameter.