Free-Form Syntax

To begin a free-form calculation group, specify /FREE in positions 7 to 11 and leave positions 12 to 80 blank. The free-form calculation block ends when you specify /END-FREE.

In a free-form statement, the operation code does not need to begin in any specific position within columns 8–80. 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 are not required by the operation, you may 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.

For the EVAL or CALLP operation code, you can omit the operation code, if no extenders are needed, and if the variable or prototype does not have the same name as an operation code. For example, the following two statements are equivalent:

 eval pos = %scan (',': name);
 pos = %scan (',': name);

For each record within a free-form calculation block, positions 6 and 7 must be blank.

You can specify compiler directives within a free-format calculation block, with the following restrictions:

Free-form operands can be longer than 14 characters. The following are not supported:

To indicate the start of total calculations, end the free-form group and code a fixed-form calculation specification with a control level specified in positions 7-8. The total calculations may be specified 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 using the statement "IF *INLx;".

Figure 159. Example of Free-Form Calculation Specification
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
 /free

         read  file;              // Get next record
         dow not %eof(file);      // Keep looping while we have
                                  // a record
             if %error;
                 dsply 'The read failed';
                 leave;
             else;
                 chain(n) name database data;
                 time = hours * num_employees
                          + overtime_saved;
                 pos = %scan (',': name);
                 name = %xlate(upper:lower:name);
                 exsr handle_record;
                 read file;
             endif;
         enddo;

      begsr handle_record;
         eval(h) time = time + total_hours_array (empno);
         temp_hours = total_hours - excess_hours;
         record_transaction();
      endsr;

 /end-free

You can combine free-form and traditional calculation specifications in the same program, as shown below:

Figure 160. Example that Combines Traditional and Free-Form Calculation Specifications
C                   testb     OPEN_ALL      flags                    10
 /free
          if *in10;
            openAllFiles();
          endif;
 /end-free

 



[ Top of Page | Previous Page | Next Page | Contents | Index ]