Free-Form Statements

When the first line of the source contains **FREE, the source is fully free-form, and free-form statements can appear anywhere between column 1 and the end of the line. There is no limit on the length of the line.

Otherwise, the source is column-limited, and a free-form statement is coded in columns 8-80. Columns 6-7 must be blank.

In most cases, a free-form statement begins with an operation code, such as CTL-OPT, DCL-F, DCL-DS, READE, or DCL-PROC.

In some cases, it is not necessary to specify the operation code.
  • In a calculation statement, the EVAL operation code and the CALLP operation code omitted as long as the first name in the statement is not the same an operation code supported in free-form calculations. For example, the EVAL operation code is required if the target of the assignment has the name READ.
  • When defining a subfield, the DCL-SUBF operation code may be omitted as long as the name of the subfield is not the same as an operation code supported in free-form calculations.
  • When defining a parameter, the DCL-PARM operation code may be omitted as long as the name of the parameter is not the as same an operation code supported in free-form calculations.

A free-form statement ends with a semicolon.

In general, all text following // on a free-form line is considered to be a comment. However, if // appears within a character literal, it is considered to be part of the literal. In the following example,  1 ,  2 ,  4 , and  6  are comments, but  3  and  5  are not comments because // appears within a literal.

 3  is followed by + which indicates that the literal is continued on the next line.  5  is followed by a quotation mark which ends the literal, and the + indicates that the literal is concatenated with the literal on the next line.

When // follows non-comment code on the same line, it is often referred to as an end-of-line comment. The comments at  2  and  4  are end-of-line comments.

  // comment  1 
  DCL-S string // comment  2 
        CHAR(10);
  string = 'abc // not-comment  3  +
           def'; // comment  4 
  string = 'ghi // not-comment  5 ' +
           'jkl'; // comment  6 
Note: In column-limited free-form source, any text that appears after column 80 must be preceded by //. However, if the source line contains a continued character literal, no text is allowed following column 80.
In the following example, the commented text beyond column 80 is valid for lines 1, 2, 3, and 5, marked with  1 . However, it is not valid for line 4, marked with  0 , because line 4 ends with a continued character literal.

 ...+... 1 ...+... 2 ...+... 3 ... // 7 ...+... 8 ...+... 9 ...+
1           a = 'abc';                           // comment  1 
2           b = 'abc' +                          // comment  1 
3               'def';                           // comment  1 
4           c = 'abc +                           // comment  0 
5               def';                            // comment  1 

For a list of operation codes supported in free-form calculations, see Operation Codes.