WEOFSEQ statement

Syntax

WEOFSEQ file.variable [ON ERROR statements]

Description

Use the WEOFSEQ statement to write an end-of-file (EOF) mark in a file opened for sequential access. The end-of-file mark is written at the current position and has the effect of truncating the file at this point. Any subsequent READSEQ statement has its ELSE statements executed.

file.variable specifies a file opened for sequential access. If file.variable evaluates to the null value, the WEOFSEQ statement fails and the program terminates with a run-time error message.

Note: On Windows systems, you cannot use the WEOFSEQ statement with a diskette drive that you opened with the OPENDEV statement. For 1/4- inch cartridge tape drives (60 MB or 150 MB) you can use WEOFSEQ to write an end-of-file (EOF) mark at the beginning of the data or after a write.

The ON ERROR Clause

The ON ERROR clause is optional in the WEOFSEQ statement. The ON ERROR clause lets you specify an alternative for program termination when a fatal error is encountered during processing of the WEOFSEQ statement.

If a fatal error occurs, and the ON ERROR clause was not specified, or was ignored (as in the case of an active transaction), the following occurs:

  • An error message appears.
  • Any uncommitted transactions begun within the current execution environment roll back.
  • The current program terminates.
  • Processing continues with the next statement of the previous execution environment, or the program returns to the command prompt.

A fatal error can occur if any of the following occur:

  • A file is not open.
  • file.variable is the null value.
  • A distributed file contains a part file that cannot be accessed.

If the ON ERROR clause is used, the value returned by the STATUS function is the error number.

See the OPENSEQ statement, READSEQ statement, and WRITESEQ statements for more information about sequential file processing.

Note: Some systems do not support the truncation of disk files. WEOFSEQ is ignored on these systems, except that WEOFSEQ always works at the beginning of a file.

Example

The following example writes an end-of-file mark on the record RECORD in the file TYPE1:

OPENSEQ 'TYPE1','RECORD' TO FILE ELSE STOP
WEOFSEQ FILE