Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

CREATE

Description

This statement is intended to create files. It can be useful after an OPENSEQ statement to create a record in a directory file. CREATE creates the record or file if the OPENSEQ statement fails.

It takes the general form:

CREATE file.variable {THEN statements [ELSE statements] | ELSE statements}

If the record or file is created, it executes the THEN statements; if no record or file is created, it executes the ELSE statements.

An OPENSEQ statement for the specified file variable must be executed before the CREATE statement to associate the pathname or record ID of the file to be created with the file variable. If file.variable is null, the CREATE statement fails and the program enters the debugger.

Note:

CREATE statement may prove useful for exception handling, when OPENSEQ cannot find a record or file to open and the next operation is to be a READSEQ or READBLK. If the first file operation is a WRITESEQ, WRITESEQ creates the record or file if it does not exist.

In the following example, record_file2 does not yet exist. When OPENSEQ fails to open record_file2 in the TESTENV directory, the CREATE statement creates and opens it to the file variable FILE, ready to be written to.

001    INCLUDE JBC.h
002    OPENSEQ 'TESTENV':DIR_DELIM_CH:'record_file2' TO FILE ELSE
003        CREATE FILE ELSE ABORT
004    END
005
006    WEOFSEQ FILE
007    WRITESEQ 'I am a test record' TO FILE ELSE
008        CRT 'Failed to write'
009    END


Go back to jBASE BASIC.


Was this article helpful?