Free-Form Calculation Statement
See Free-Form Statements for information on the columns available for free-form statements.
In a free-form statement, the operation code does not need to begin in any specific position within the available columns. Any extenders must appear immediately after the operation code on the same line, within parentheses. There must be no embedded blanks between the operation code and extenders. Following the operation code and extenders, you specify the Factor 1, Factor 2, and the Result Field operands separated by blanks. If any of these items are not required by the operation, you can leave them out. You can freely use blanks and continuation lines in the remainder of the statement. Each statement must end with a semicolon. The remainder of the record after the semicolon must be blank or contain an end-of-line comment.
eval pos = %scan (',': name);
pos = %scan (',': name);
For each record within a free-form calculation block, positions 6 and 7 must be blank.
- The compiler directive must be the first item on the line. It cannot continue to the next line.
- In column-restricted code, the directive can start anywhere from column 7 onward.
- Compiler directives are not allowed within a statement. The directive must appear on a new line after one statement ends and before the next statement begins.
- Continuation of numeric literals
- Defining field names
- Resulting indicators. (In most cases where you need to use operation codes with resulting indicators, you can use an equivalent built-in function instead.)
To indicate the start of total calculations, code a fixed-form calculation specification with a control-level specified in positions 7-8. In fully free-form mode, this fixed-form statement must be specified in a copy file. The total calculations can be specified by using free-form calculation syntax. Since the free-form calculation specification does not include a control-level entry, calculations to be performed on specific level breaks should be conditioned by using the statement "IF *INLx;".
- Detail calculations
- Total calculations start
- Conditioning calculations by a specific control-level indicator
items += 1; 1
CL0 Total TAG 2
IF *INL1; 3
EXCEPT orderTotal;
orders += 1;
totalItems += items;
items = 0;
ENDIF;
In column-limited source, you can combine free-form and traditional calculation specifications in the same program: