CREATE

CREATE

Top  Previous  Next

 

The CREATE statement creates an empty directory file record after a previous OPENSEQ has reported that the record did not exist.

 

 

Format

 

CREATE file.var

{ON ERROR statement(s)}

{THEN statement(s)}

{ELSE statement(s)}

 

where

 

file.varis the file variable associated with the record by a previous OPENSEQ statement.

 

statement(s)are statement(s) to be executed depending on the outcome of the CREATE.

 

The ON ERROR clause is taken in the event of a fatal error that would otherwise cause the program to abort.

 

At least one of the THEN and ELSE clauses must be present. The THEN clause is executed if the operation is successful. The ELSE clause is executed if the CREATE operation fails.

 

 

Example

 

OPENSEQ 'AUDIT', DATE() TO SEQ.F THEN

  SEEK SEQ.F, 0, 2 ELSE STOP 'Seek error'

END ELSE

  IF STATUS() THEN ABORT 'Error opening audit record'

  CREATE SEQ.F ELSE ABORT 'Error creating audit record'

END

 

This program fragment attempts to open a sequential file record. If the OPENSEQ fails because the record does not exist, an empty record is created.

 

 
See also:

CLOSESEQ, NOBUF, OPENSEQ, READBLK, READCSV, READSEQ, SEEK, WEOFSEQ, WRITEBLK, WRITECSV, WRITESEQ, WRITESEQF