IB Statements/open

From CometWiki

(Difference between revisions)
Jump to: navigation, search
Badge (Talk | contribs)
(New page: '''OPEN statement''' '''Syntax:''' OPEN (lun) filename|device-name [,key=key name][,DIR=directory] [,EXCP=statement-label] '''Discussion:''' The OPEN statement opens a file or a per...)
Newer edit →

Revision as of 09:30, 20 May 2009

OPEN statement

Syntax: OPEN (lun) filename|device-name [,key=key name][,DIR=directory] [,EXCP=statement-label]

Discussion: The OPEN statement opens a file or a peripheral device using a specified logical unit number. The lun parameter is the numeric value that is assigned to the specified data file or device. The lun may be a numeric constant, numeric variable, or a symbolic constant. Its value may be from 0 through 49. The logical unit number assigned to a file or device remains in effect until the program is terminated, or until that logical unit number is closed. More than one logical unit number can be assigned to the same file or device.

The key parameter is optional, and is used to indicate which sub key to use for this logical unit number. For a discussion about using sub keys in programs go here: Keyed files

The directory parameter is optional, and is the name of the Comet directory to be searched for the specified file. It can be a string constant or a string variable, with a maximum length of three characters. If a directory is specified, only that directory is searched for the file.

Also see CLOSE.

Example 1: OPEN (1) "LP1",EXCP=9999  ! Open printer LP1 . . . CLOSE (1)


Example 2: OPEN (2) "CUSTFILE",DIR="DSK",EXCP=5000  ! Open data file . . . CLOSE (2)

Example 3:

 CLOSE (6) & OPEN (6) "WORKFILE"

In this example, logical unit number 6 is first closed, then opened and assigned to a data file named "WORKFILE." This technique guarantees that the logical unit number is available before the OPEN statement is executed.

Personal tools