IB Statements/write

From CometWiki

< IB Statements
Revision as of 22:20, 28 May 2009 by Barb (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

WRITE statement

Syntax: WRITE (lun, format-statement-label) [KEY=index] [,EXCP=statement-label | NOEXCP]

Discussion: The WRITE statement outputs data records to a keyed, sequential, or text data file. For keyed files, the key index can be any string expression. If the key index is shorter than the file key size, it is padded with trailing blanks. If it is longer than the key size, excess trailing characters are truncated before the WRITE statement is executed.

For sequential and text files, no key index is specified. In fact, doing so causes an exception branch.

Example: 1000 FORMAT CUSTNUM$;NAME$;ADDRESS1$;ADDRESS2$

.

OPEN (1) "CUSTFILE"

.

WRITE (1,1000) KEY=CUSTNUM$,EXCP=9999

In this example, the WRITE statement is used to write a data record to the CUSTFILE, a keyed file. The FORMAT statement determines the record layout of this data file and the KEY= parameter determines the key index being created.

Personal tools