IB Statements/input
From CometWiki
(New page: '''INPUT statement (new)''' '''Syntax:''' INPUT [(lun)] @(screen-position),variable-name[,length-override] where: screen-position = the column and row (respectively) where an entry f...) |
|||
(2 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | '''INPUT statement ( | + | |
+ | '''INPUT statement (legacy)''' | ||
- | '''Syntax:''' INPUT [(lun)] | + | '''Syntax:''' INPUT [(lun)] variable-list [,EXCP=statement-label | NOEXCP] |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
'''Note:''' If no lun is specified, the INPUT statement assumes lun 0. | '''Note:''' If no lun is specified, the INPUT statement assumes lun 0. | ||
- | '''Discussion:''' | + | '''Discussion:''' The INPUT statement allows simple, unformatted input into specified variables without necessarily having to reference a FORMAT statement. |
- | The | + | The variable-list consists of one or more variable names, separated by semicolons. |
- | + | '''Note:''' Each variable in a multi-variable list requires a separate operator transmission (see I/O Format Division for more information). | |
- | The field | + | The length of a string field is governed by its current length, and not by the declared length. Because unformatted input is given field-by-field, trailing blanks are stripped from each string variable in the list. This is unlike the READ statement where trailing blanks are stripped only from the last string variable listed in the FORMAT statement, and all variables are input with a single transmission. |
- | + | Using INPUT with a single variable is a convenient way to cause the system to strip the trailing blanks. As the record is placed in the variable (string), the current length is adjusted for the blank stripping. | |
- | + | If you do not include a decimal point in a numeric variable, it is automatically inserted according to the declared precision of the variable. Excess characters are truncated on the left. | |
- | + | If you do include a decimal point in a numeric variable, INPUT will adjust it with the declared precision. Excess characters (on both the left and the right) are truncated. | |
- | + | Although unformatted INPUT is primarily used for video terminal input, it can also be used for multiple sequential reads of any type of file into a list of single variables, one for each record. | |
- | + | ||
- | + | INPUT can also refer to a FORMAT statement. It functions the same way as a non-indexed READ statement. In this case, the syntax is: | |
- | + | INPUT (lun,format-statement-label) [,EXCP=statement number] | |
- | + | ||
- | : | + | '''Note:''' Another form of the INPUT statement exists. It creates an input field without transmit marks. See the new INPUT statement for more information. |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | The INPUT statement | + | '''History:''' The INPUT statement was enhanced in Comet version 504.208. Additional status information is available following the execution of an INPUT statement. This information includes the location of the cursor when the INPUT occurred, and a flag that identifies the keyboard action that caused the INPUT. |
- | + | '''Reason for transmit''' | |
+ | Immediately following the execution of an INPUT statement, the console's status now contains a flag that identifies the key that caused the transmit to occur. This information is stored in the 8th byte of the console's status buffer, and is stored in hex. | ||
- | + | This information remains in the console's status buffer until a subsequent INPUT statement is executed. | |
- | + | ||
- | ' | + | |
- | + | To inquire on this field, perform the following operation: | |
- | + | ||
- | + | ||
- | + | VALUE = ASC(SUB(STS(0),8,1)) | |
- | + | Note: VALUE is a numeric field with length/precision of 3.0. | |
- | + | The following values are returned: | |
- | + | Value Key that caused the transmit to occur | |
+ | 1 F10 | ||
+ | 2 Enter (either key) | ||
+ | 3 Tab | ||
- | |||
- | |||
- | + | Additional values are returned when the (Easy Scan) mnemonic is invoked. | |
- | |||
- | + | '''Cursor location''' | |
+ | Immediately following the execution of an INPUT statement, the console's status also contains the location of the cursor when the transmit occurred. This information is stored in the 9th and 10th bytes of the console's status buffer, and is stored in hex. | ||
- | + | This information remains in the console's status buffer until a subsequent INPUT statement is executed. | |
- | + | To inquire on these fields, perform the following operations: | |
- | + | X = ASC(SUB(STS(0),9,1)) | |
+ | Y = ASC(SUB(STS(0),10,1)) | ||
- | + | Note: X and Y, the screen coordinates, are numeric fields with length/precision of 3.0. | |
+ | |||
+ | '''Example 1:''' PRINT (0) "ENTER CUSTOMER NAME:" ! Display prompt | ||
- | ! | + | INPUT (0) CUSTNAME$ ! Enter data |
- | + | ||
- | + | '''Example 2:''' 1000 FORMAT NAME$;ADDRESS$;CITY$;STATE:ZIP$ | |
- | + | . | |
- | + | . | |
- | + | . | |
- | + | PRINT (0,500) ! Formatted screen | |
- | + | INPUT (0,1000) ! Input items in FORMAT statement | |
- | + | ||
- | INPUT | + | |
- | + | ||
- | ! | + | |
- | + | ||
- | |||
- | '''Example | + | '''Example 3:''' INPUT (0) A$;B$;C$ |
- | + | (or) | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
+ | 100 FORMAT A$;B$;C$ | ||
. | . | ||
- | |||
. | . | ||
- | |||
. | . | ||
+ | INPUT (0,100) | ||
- | + | The first INPUT statement requires a separate transmission for each of the three fields. Also, blanks are stripped from each field. In the second example, only one transmission is required (as shown by the single INPUT statement). In this case, blanks are stripped only from the final field (C$ in the above example). | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + |
Latest revision as of 22:14, 28 May 2009
INPUT statement (legacy)
Syntax: INPUT [(lun)] variable-list [,EXCP=statement-label | NOEXCP]
Note: If no lun is specified, the INPUT statement assumes lun 0.
Discussion: The INPUT statement allows simple, unformatted input into specified variables without necessarily having to reference a FORMAT statement.
The variable-list consists of one or more variable names, separated by semicolons.
Note: Each variable in a multi-variable list requires a separate operator transmission (see I/O Format Division for more information).
The length of a string field is governed by its current length, and not by the declared length. Because unformatted input is given field-by-field, trailing blanks are stripped from each string variable in the list. This is unlike the READ statement where trailing blanks are stripped only from the last string variable listed in the FORMAT statement, and all variables are input with a single transmission.
Using INPUT with a single variable is a convenient way to cause the system to strip the trailing blanks. As the record is placed in the variable (string), the current length is adjusted for the blank stripping.
If you do not include a decimal point in a numeric variable, it is automatically inserted according to the declared precision of the variable. Excess characters are truncated on the left.
If you do include a decimal point in a numeric variable, INPUT will adjust it with the declared precision. Excess characters (on both the left and the right) are truncated.
Although unformatted INPUT is primarily used for video terminal input, it can also be used for multiple sequential reads of any type of file into a list of single variables, one for each record.
INPUT can also refer to a FORMAT statement. It functions the same way as a non-indexed READ statement. In this case, the syntax is:
INPUT (lun,format-statement-label) [,EXCP=statement number]
Note: Another form of the INPUT statement exists. It creates an input field without transmit marks. See the new INPUT statement for more information.
History: The INPUT statement was enhanced in Comet version 504.208. Additional status information is available following the execution of an INPUT statement. This information includes the location of the cursor when the INPUT occurred, and a flag that identifies the keyboard action that caused the INPUT.
Reason for transmit Immediately following the execution of an INPUT statement, the console's status now contains a flag that identifies the key that caused the transmit to occur. This information is stored in the 8th byte of the console's status buffer, and is stored in hex.
This information remains in the console's status buffer until a subsequent INPUT statement is executed.
To inquire on this field, perform the following operation:
VALUE = ASC(SUB(STS(0),8,1))
Note: VALUE is a numeric field with length/precision of 3.0.
The following values are returned:
Value Key that caused the transmit to occur 1 F10 2 Enter (either key) 3 Tab
Additional values are returned when the (Easy Scan) mnemonic is invoked.
Cursor location
Immediately following the execution of an INPUT statement, the console's status also contains the location of the cursor when the transmit occurred. This information is stored in the 9th and 10th bytes of the console's status buffer, and is stored in hex.
This information remains in the console's status buffer until a subsequent INPUT statement is executed.
To inquire on these fields, perform the following operations:
X = ASC(SUB(STS(0),9,1)) Y = ASC(SUB(STS(0),10,1))
Note: X and Y, the screen coordinates, are numeric fields with length/precision of 3.0.
Example 1: PRINT (0) "ENTER CUSTOMER NAME:" ! Display prompt
INPUT (0) CUSTNAME$ ! Enter data
Example 2: 1000 FORMAT NAME$;ADDRESS$;CITY$;STATE:ZIP$
.
.
.
PRINT (0,500) ! Formatted screen
INPUT (0,1000) ! Input items in FORMAT statement
Example 3: INPUT (0) A$;B$;C$
(or)
100 FORMAT A$;B$;C$ . . . INPUT (0,100)
The first INPUT statement requires a separate transmission for each of the three fields. Also, blanks are stripped from each field. In the second example, only one transmission is required (as shown by the single INPUT statement). In this case, blanks are stripped only from the final field (C$ in the above example).