Previous Topic Next topic Print topic


N run-time switch

Enables null insertion for all line sequential files in your program.
Restriction: These switches are supported for native COBOL only.

Properties:

Default: On
Type: File handling

Comments:

This switch is especially useful if the format of your files is incompatible with this COBOL system.

Setting this switch to on means that when a program writes records to a line sequential file with a record containing control characters (that is, all characters with ASCII codes less than or equal to x"1F"), the system adds a null character (x"00") before each control character. Similarly, on reading a record from a line sequential file, these null characters are stripped from the control characters.

Setting this switch affects only the physical storage of data in a line sequential file. Records written with one setting and read back with the same setting are returned in exactly the same way. However, if you try to read a file with one setting which was written with the other setting, the results are unpredictable.

Setting this switch off enables control characters to be written and read in the same way as other characters.

When the N switch is on:

  • Any character is allowed in the data record of a line sequential file.
  • Each record is examined before it is written. All characters whose value is less than or equal to x"1F" are written with a preceding null (x"00") to form two-byte pairs. On output to disk, trailing spaces are removed, and a record terminator of x"0D0A" is appended to terminate the record.
  • The file is read as records, some of which might contain two-byte pairs where the first byte is null. The records are terminated by a record terminator. The leading null of each two-byte pair is removed to give the final data record. Tabs (x"09") that do not form part of a two-byte pair are expanded.

The File Handler configuration option INSERTNULL takes precedence over the N run-time switch:

Note: Control characters depend on the operating system. Their hexadecimal values are always less than x"1F".

When the N switch is off:

  • Data records in a line sequential file must contain only ASCII text characters (those with a value greater than x"1F").
  • Trailing spaces are removed on output to disk, and a record terminator of x"0D0A" is appended to terminate the record. Printer control characters might also be written to disk.
  • The file is read as data records with each record terminated by a record terminator. If the data contains either x"0D" or x"0A", results can be unpredictable. Tab characters (x"09") are expanded to spaces; otherwise the data record is returned intact.

Example:

The command:

cobrun[_t] -N myprog

loads the program Myprog. It also specifies that, in line sequential files, all characters less than or equal to x"1F", except for Tab and the file control characters, are treated as data. Null is not inserted before data characters less than x"1F" on output.

Previous Topic Next topic Print topic