File Access Modes


 

Any file (FILE, IFILE, or AFILE) may be opened or prepared in one of four access modes; SHARE, SHARENF, EXCLUSIVE, or READ. CREATE and PREPARE keywords are also supported and are treated as SHARE. Files may be accessed in modes different than they were originally created or may be accessed in more than one mode at a time, within the rules for each mode described in these sections:

 

EXCLUSIVE File Access

READ (Only) File Access

SHARE File Access

SHARENF File Access

 

The mode may be a keyword or a decimal number or Numeric Variable as follows:

Generate/bullet1.gif    Valid keywords are EXCLUSIVE, READ, SHARE, and SHARENF.

Generate/bullet1.gif    Decimal number or Numeric Variable (four byte INTEGER) values specify bit maps as follows:

 

Keyword

Value

Meaning

CMP_EOR_MASK

0xF

Mask for all EOR bit definitions

CMP_EOR_CR

0x1

MODE input request EOR type CR only.

CMP_EOR_CRLF

0x2

MODE input request EOR type CRLF.

CMP_EOR_LF

0x4

MODE input request EOR type LF only.

CMP_EOR_LFCR

0x8

MODE input request EOR type LFCR.

CMP_OPEN_MASK

0x70

File mode mask in OPEN/PREP.

CMP_SHARE

0x0

Share mode requested in OPEN/PREP when no bit is set within the bit definition mask range defined by CMP_OPEN_MASK

CMP_EXCLUSIVE

0x10

Exclusive mode requested in OPEN/PREP.

CMP_SHARENF

0x20

Share NoFlush requested in OPEN/PREP.

CMP_READ

0x40

Read mode requested in OPEN/PREP.

CMP_NOPREPTRUNC

0x400

Prep AFILE/IFILE without truncating the txt file.

CMP_NO_OPT_TRAN

0x1000

Do not put file under an optimistic transaction.

CMP_RESERVED

0x80000000

DO NOT USE. This bit is ignored by the runtime.

 

The {mode} keyword option expands functionality and makes OPEN or PREP instructions more dynamic for a user program. When the mode bit definitions specifies an EOR type, this EOR type overrides a type specified by a FORMAT keyword on a AFILE/FILE/IFILE variable declaration. In addition, the inclusion of an EOR type in the MODE causes the runtime to verify that the EOR type of a pre-existing file is the same as required by the MODE settings for all cases except when FORMAT=BINARY is specified in the file declaration. An error occurs if this EOR verification fails.

 

 

See Also: Disk I/O Instructions

 



PL/B Language Reference Associative Access Method EXCLUSIVE File Access