# 8.2 General Rules for Writing FORMAT Statements

This section summarizes the rules for constructing and using format specifications and their components in FORMAT statements. It also summarizes the rules for constructing external fields and records.

The following are general FORMAT statement rules:

- A FORMAT statement must always be labeled.

- In a field descriptor such as rIw[.m] or nX, the terms r, w, m, and n must be unsigned integer constants or variable format expressions. These terms cannot be names assigned to constants in PARAMETER statements. You can omit the repeat count and field width specification. (See Section 8.1 for the range of values for r, w, m and n.)

- In a field descriptor such as Fw.d, the term d must be an unsigned integer constant or variable format expression. You must specify d with F, E, D, and G field descriptors even if d is zero. The decimal point is also required. You must either specify both w and d, or omit them both. In a field descriptor such as Ew.dEe, the term e must also be an unsigned integer constant.

- In an edit descriptor such as nHc1c2...cn, exactly n characters must follow the H format code. You can use any printable ASCII character in this edit descriptor.

- In a scale factor of the form nP, n must be an integer constant in the range of -128 to 127, or a variable format expression. The scale factor affects the F, E, D, and G field descriptors only. Once you specify a scale factor, it applies to all subsequent real field descriptors in that format specification until another scale factor appears. You must explicitly specify 0P to reinstate a scale factor of zero. Format reversion does not affect the scale factor.

- The numeric field descriptors ignore leading spaces in the external field. Embedded and trailing spaces are ignored only if the BN edit descriptor is specified or if BLANK=`'` NULL`'` is in effect for the logical unit. Otherwise, embedded and trailing spaces are treated as zeros.

- No repeat count is permitted in edit descriptors BN, BZ, S, SS, SP, H, Q, X, T, TR, TL, $, :, or character constants unless these descriptors are enclosed in parentheses and treated as group repeat specifications.

- If the associated I/O statement contains an I/O list, the format specification must contain at least one field descriptor (I, O, Z, F, E, D, G, L, or A) or the edit descriptor Q.

- A format specification in a character variable, character substring reference, character array element, character array, character expression, numeric array, or numeric array element must be constructed in the same way as a format specification in a FORMAT statement, including the opening and closing parentheses.

- If a character-constant format includes apostrophes as delimiters, the apostrophes must be represented by two consecutive apostrophes (' ') with no spaces or characters between them.

Previous Page Next Page Table of Contents