• Keine Ergebnisse gefunden

THE ACCEPT STATEMENT

Im Dokument BASIC Language Reference vs (Seite 121-124)

CHAPTER 3 DATA FORMATS

7.5 THE ACCEPT STATEMENT

ACCEPT is the most versatile of the VS workstation I/O conunands. A single ACCEPT statement displays a formatted screen of data at the workstation, which can include literal messages as well as the values of numeric and alpha expressions. You can enter new values for

receivers that is displayed on the screen. Note that ACCEPT processes an entire screen full of data at one time, instead of one line at a time, as is done by INPUT. An ACCEPT statement consists of the word ACCEPT, followed by a list of items to be displayed on the workstation screen. A single ACCEPT statement can perform any or all of the

following functions, depending on how you use the various optional clauses:

1. Display literal messages.

2. Display current values of variables and alpha receivers in an optionally specified format (PIC, CH clauses).

3. Control placement of displayed literals and receivers (AT clause).

4. Control Display mode of displayed receivers (FAC clause).

5. Accept modifications to the values of displayed receivers.

6. Validate modifications to receivers to confirm that they are within a specified range of values (RANGE clause).

7. Accept input from PF keys (KEYS, KEY clauses).

8. Branch to different places in a program depending upon your response to the ACCEPT statement (ON and NOALT clauses).

For the general form of the ACCEPT statement, refer to Part II.

Sections 7.5.1 through 7.5.4 illustrate the use of each of the optional clauses by example.

7.5.1 Screen Formatting

Fields

When an ACCEPT statement is executed, the entire screen is cleared and a screen is displayed containing items specified in the ACCEPT

statement. The items that can be displayed are literal messages, numeric variables, and alpha receivers. Unless you specify otherwise, new values can be entered for variables and alpha receivers by typing over the displayed values. You cannot modify displayed literals.

Each item that is displayed occupies a field on the CRT screen. A field is a sequence of adjacent character positions on the workstation screen that is associated with a particular item in an ACCEPT

statement. The width of each field is equal to the number of characters required to display the item. In the case of literals, this is simply the length of the literal itself. For alpha receivers, use the defined length as the field width unless some other width is specified with a CH clause. Field width for numeric variables is 18 characters unless some other width is specified with a PIC clause.

ACCEPT shows the field that a variable or alpha receiver occupies by displaying all blank spaces in the field as pseudoblanks. These appear on the screen as solid squares, and are shown in the following examples as underscores. For example,

100 A

=

99

200 B$

=

"BOTTLES"

300 ACCEPT A, B$, "OF BEER ON THE WALL."

400 PRINT A, B$

generates a screen containing the line

99 BOTTLES OF BEER ON THE WALL.

~---~

-The value of A is displayed in a field 18 characters wide: a leading pseudoblank is shown where a minus sign would be displayed if the value were negative, followed by the digits 99, followed by 15 trailing pseudoblanks. Since B$ was not explicitly dimensioned, it has a default length of 16 characters. Thus, 9 pseudoblanks are shown following BOTTLES. The literal OF BEER ON THE WALL is displayed

exactly as written, with no pseudoblanks. Note that a space is displayed before the beginning of each field. This space contains a Field Attribute Character (refer to Section 7.3.3).

Positioning Data on the Screen: The AT Clause

Use the AT clause to position a field anywhere on the screen by specifying the row and column of the screen at which a particular field begins. In the example above, the first value was displayed starting at the second column of the first row; the first column of every row is inaccessible for displaying data, since it always contains a FAC. By changing line 300 to

300 ACCEPT AT (12, 25), A, B$, AT (13, 25), "BEER ON THE WALL."

the following appears in the center of the screen (starting at the twenty-fifth column of rows 12 and 13):

99 BOTTLES

-OF BEER ON THE WALL.

If no AT clause is specified for a field, the field is positioned according to the default rules specified under the ACCEPT statement in Part II.

Controlling Display Attributes for a Field: The FAC Clause

In addition to controlling the position of literal and receiver fields on the screen, the ACCEPT statement allows you to specify the display attributes of a field. The display attributes determine whether a field is: dim, bright, blinking, or not displayed; modifiable or protected; containing uppercase, numeric, or all characters;

underlined or not underlined. Display attributes are controlled by displaying a Field Attribute Character inunediately preceding a field.

For example, in the example above, changing line 300 to 300 ACCEPT AT (12,25), A, FAC{HEX(91)), B$, AT (13,25), 350 "OF BEER ON THE WALL."

causes the same message as before to be displayed, except that the B$

field {containing the string BOTTLES) blinks, since HEX{91) is the FAC specifying blink, modifiable, uppercase, no line.

If the display attributes for a particular field are not explicitly defined with a FAC clause, the following defaults are used:

Alphanumeric

Floating-point

Integer

Bright, modifiable, uppercase, no underline (HEX(81)).

Bright, modifiable, uppercase, no underline (HEX(81)).

Bright modifiable, numeric only, no underline (HEX(82)).

Note that FACs cannot be specified for literal fields, which are

always shown preceded by a FAC of HEX(AC} (dim, protect, all, no line).

Format Images of Displayed Receivers: The PIC and CH Clauses It is often useful to be able to display modifiable data fields in formats other than the default formats described in the preceding list. This can be done with the PIC clause for numeric fields and with the CH clause for alpha fields. Each of these optional clauses appears directly after the receiver it modifies in the ACCEPT

statement, separated from the receiver by a comma. The PIC clause specifies a format image for numeric data, and the CH clause specifies

a field width in characters. (For a description of all the editing ~

characters that can be used in a PIC clause, refer to the discussion of this clause under the FMT statement in Part II.) For example, if you know that the variable A will never require more than three character positions to be displayed, the statement

300 ACCEPT AT (12,20),A,PIC(###),B$,CH(7), "OF BEER ON THE WALL."

will display

Im Dokument BASIC Language Reference vs (Seite 121-124)