Option (statement)

From Br Wiki
Jump to: navigation, search

See also Option (disambiguation).

The Option statement defines one or more of three options for a program: BASE 0 or BASE 1 for array dimensions and subscripts; inverted printing of decimal points and commas in numeric values (change to European style); and COLLATE NATIVE or COLLATE ALTERNATE.

1.) A user-defined collating sequence may now be accessed when OPTION COLLATE ALTERNATE is specified. SEE COLLATE ALTERNATE in the BRConfig.sys specification section for more information.
2.) The OPTION statement now accepts the RETAIN parameter. The option statement with the RETAIN parameter may be used in a library program to specify that -when the library is loaded resident global variables should retain their values irrespective of the status of the main program.

Comments and Examples

The system checks an entire program for the OPTION statement before it begins execution; no matter where the statement appears, it applies to the whole program.

In the following example, OPTION specifies that the program's array dimensions and subscripts should use base 0 and that the alternate collating sequence should be used:

08000 OPTION BASE 0, COLLATE ALTERNATE

Commas must be used between options when more than one is specified in a statement. They must be omitted, however, when only one option is indicated.

When the statement OPTION INVP is used, the system inverts the normal printing of commas and periods in numeric values. (For ease of understanding, the inverted format will be referred to as the European style, and the standard format will be called the U.S. style.) This parameter remains in effect even after a program is over. It can be removed with an explicit CLEAR command or with an implicit CLEAR as is automatically performed by commands or statements such LOAD, RUN, CHAIN, and INDEX. OPTION INVP also affects input from the keyboard when required by INPUT, INPUT FIELDS and RINPUT FIELDS statements. In line 20 below, the number 22.111,00 would be valid input and 22,111.00 would generate an error:

00010 OPTION INVP
00020 INPUT FIELDS "9,9,PIC(ZZ,ZZZ.##),U": NUMBR

Syntax

OPTION [ BASE {0|1}] [, INVP ] [, COLLATE {NATIVE|ALTERNATE}]

Option.png

Defaults

1.) BASE 1.
2.) Use U.S. format for commas and decimals in numeric values.
3.) Use the collating sequence listed in the BRConfig.sys file. If none is specified there, use COLLATE NATIVE.
4.) When a library program is loaded resident, do not retain global variables after the main program ends.

Parameters

The "BASE" parameter allows you to choose between BASE 0, which specifies that every array includes a zero element, and BASE 1, which indicates that every array begins with element 1. If an array has two or more dimensions, OPTION BASE applies to all dimensions.

"INVP" instructs the system to invert the normal printing of commas and periods in numeric values to support European notation. A number such as 98,248.6 would appear as 98.248,6 when INVP is indicated. INVP affects:

1.) Both input and output to formatted disk files.
2.) PRINT, PRINT USING and PRINT FIELDS output.
3.) INPUT, INPUT FIELDS and RINPUT FIELDS input from the keyboard.

The "COLLATE" parameter allows you to specify your collating sequence. COLLATE can also be specified in BRConfig.sys, but this is overridden by the collating sequence in the OPTION statement.

COLLATE NATIVE specifies the ASCII collating sequence. In this sequence, the binary representations of the numbers 0-9 precede those of the uppercase letters A-Z, which in turn precede their lowercase counterparts. The numbers 0-9, then, are represented by ASCII codes 048-057; uppercase letters are represented by ASCII codes 065-090, and lowercase letters are represented by codes 097-122.
(See a complete listing of ASCII codes for details.)

The COLLATE ALTERNATE specification specifies a collating sequence similar to EBCDIC in that the numbers 0-9 follow uppercase and lowercase letters (other values will differ). With COLLATE ALTERNATE, 0-9 are represented by codes 176-195.

Technical Considerations

1.) When chaining from one program to another, OPTIONs in both programs should be identical (see Technical Considerations under the CHAIN statement).
2.) The OPTION statement must appear alone on a line.
3.) OPTION INVP affects PIC, L, N, NZ, G and GZ format specifications.
4.) OPTION INVP stays in effect after the program is over. It remains in effect until a CLEAR command is executed either explicitly or implicitly as part of a LOAD, RUN, CHAIN, INDEX, etc.
5.) OPTION INVP does not apply to DATA statements and numeric constants. Periods (not commas) are still required as the decimal point (this saves many potential programming changes when preparing your programs for non-U.S. markets).
6.) Although it effects program execution, OPTION is not considered an executable statement; thus, it may be placed anywhere in the program.
7.) Only one OPTION statement is allowed in a program.
8.) For other features useful in foreign markets, see the PIC$ and DATE$ functions.