FILE


ANSI

 

The FILE instructions define files that are used for sequential or random file I/O. Sequential files read or write data in sequential order, while random files read or write data sequentially or directly by random record number. The instruction uses one of the following formats:

 

(1)

[label]

FILE

[%][*][({arraysize})][{parm}]

(2)

[label]

RFILE

[*][{parm}]

(3)

[label]

FILE

^,{target}]

(4)

[label]

FILE

^({arraysize})[,({target}),...,({target})]

(5)

[label]

FILE

%%[({arraysize})]

 

Where:

label

Optional. A Program Execution Label.

%

Optional. Denotes the item as being GLOBAL.

*

Optional. Denotes the item as being COMMON.

arraysize

Optional. An Integer decimal constant, CONST variable or equated value indicating the number of array items.

parm

Optional. One of the valid parameters listed below.

^

Optional. Denotes the item as being a POINTER.

target

Optional. A previously declared FILE variable that initializes the array.

%%

Optional. Denotes the item as GLOBAL but does not initialize it in any way.

Flags Affected: NONE

Note the following:

  1. A FILE must have been defined with a FILE Definition instruction before being referenced in a file I/O instruction. An RFILE is treated as a FILE by the compiler.

  2. {parm} is optional. The supported parameters are:

  3. BUFFER={nnnn | nvar | exp}

    This parameter establishes a buffer for I/O operations equal to {nnnn} bytes, the value of the previously defined numeric variable {nvar}, or the value of a numeric expression {exp}. When performing sequential I/O, this buffer is used strictly for read and write caching. When performing random I/O, the BUFFER is the actual sector length, including the EOR character(s). The maximum allowed value is 65533.

    COBOL

    This parameter provides compatibility with other compilers and is simply ignored.

    COMP or COMPRESSED

    Allows space compression and variable lengths of records within the file. The VAR parameter is assumed in this case. Space compression is performed using the operating system standards.

    DYNAMIC

    This parameter provides compatibility with other compilers and is simply ignored.

    FIX={nnnn | nvar | exp} or FIXED={nnnn | nvar | exp}

    For SUNDBSYx, the FIXED parameter functions in the same manner as BUFFER, except when performing random I/O, the byte count is automatically (by the compiler) incremented by one (Linux) or two (MS-DOS) to accommodate the EOR character(s).

    For PLBCMP and related runtimes when performing both random I/O and sequential I/O, the byte count is automatically (by the compiler) incremented by one (Linux) or two (MS-DOS) to accommodate the EOR character(s), up to the defined record length. For WRITEs, records longer than the defined length is truncated and shorter records is padded with spaces to the defined record length. For sequential I/O, the FIXED parameter can be made to function in the same manner as BUFFER by specifying the keyword PLB_FIXED={ON | OFF}. The maximum allowed value is 65533.

    FORMAT={MSDOS | UNX | BINARY}

    This parameter sets the end of record indicator within the file. The MSDOS type terminates records with a carriage return followed by a line feed for an end of record mark. The UNX type terminates records with a single line feed. The BINARY type does no checking on the file for the end of record type.

    OVERLAP

    This parameter provides compatibility with other compilers and is simply ignored.

    UNCOMP or UNCOMPRESSED

    This parameter does not permit space compressed records unless the VARIABLE parameter is also present.

    VAR={nnnn | nvar | exp} or VARIABLE={nnnnn | var | exp}

    This parameter functions as does the BUFFER parameter for FILE definitions.

    VIEW={viewname}

    This parameter specifies a default view used for the file variable. The {viewname} can be a literal or a character string variable that specifies a database and view name.
     
  4. Additional parameters supported when using Datapoint Corporation's RMS Remote Access Server (RMSRAS) are as follows:

  5. FORMAT={BINARY | BIT8 | RMS | RMSUNCOMP}

    This parameter allows definition of the file type as specified.

    INCREMENT={nn}

    This parameter defines the file increment value.

    LENGTH={nn}

    This parameter specifies the record length.

    STATIC={nn}

    This parameter defines the number of buffers allocated to the file. It is provided for compatibility only and is ignored by the runtime.
     
  6. If none of the above parameters are given, BUFFER=256 is assumed. This establishes a buffer and sector length of 256 bytes for all I/O operations.

  7. If the operand field begins with an asterisk (*), the file is a Common Data Item. An attempt is made to maintain the OPEN status (with existing file pointers intact) of a corresponding file declaration in the program that initiated the chain. However, if the UDA of the chained to program is not in alignment (same File Definition types, sizes, and locations) with those in the program that initiated the CHAIN, a CHAIN error occurs.

  8. The ^ denotes a Pointer Variable.

  9. If the % form is used, the data item is placed in the Global Data Area. The variable would be available to other programs that also declared it with the percent form. Global Data Items are available with PLBCMP only.

  10. If the %% form is used, the data label is placed in the Global Data Area but no initialization takes place if it has not already been defined in the Global Data Area. Global Data Items are available with PLBCMP only.

  11. Array definition and referencing is handled in the same manner as DIM variables.

 

 

See Also: Example Code, File Definitions, Disk I/O Instructions

 



PL/B Language Reference COMFILE FILELIST