IB Statements/input

From CometWiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
'''INPUT statement (new)'''
 
-
 
-
'''Syntax:'''  INPUT [(lun)] @(screen-position),variable-name[,length-override]
 
-
where:
 
-
screen-position = the column and row (respectively) where an entry field will be created
 
-
variable-name = the name of the input variable
+
'''INPUT statement (legacy)'''
-
 
+
-
length-override = the size of the entry area (number of characters)  
+
'''Syntax:'''  INPUT [(lun)] variable-list [,EXCP=statement-label]
'''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:'''  This form of the INPUT statement creates a data entry field at the specified screen-position. It differs from the legacy INPUT statement in the following ways:
+
'''Discussion:'''  The INPUT statement allows simple, unformatted input into specified variables without necessarily having to reference a FORMAT statement.  
-
The entry field is created automatically by Comet
+
The variable-list consists of one or more variable names, separated by semicolons.
-
It does not require transmit marks
+
'''Note:''' Each variable in a multi-variable list requires a separate operator transmission (see I/O Format Division for more information).
-
The field type and length/precision are validated by Comet
+
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.
-
It supports multiple entry fields and a specified "tab order"
+
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.
-
For example, suppose your program includes a string variable named A$ with a declared length of 10 bytes. The following statement creates a 10-byte entry field starting at column 20, row 12:
+
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.  
-
:INPUT @(20,12),A$
+
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.
-
If you include a length-override parameter, and if the specified length is less than the declared field length, the input data will scroll horizontally if the cursor moves beyond the bounds of the field's entry area. (If the length-override is greater than the declared field length, the lenght-override is not used; the field size is determined by the declared length.)
+
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.  
-
For example:
+
-
INPUT @(20,12),A$,5
+
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:
-
In this case, the entry field will be 5 characters, even though the declared length of the field is 10 bytes.
+
INPUT (lun,format-statement-label) [,EXCP=statement number]
-
Suppose your program includes a numeric variable named X with a declared length/precision of 8.3. The following statement creates a right-justified entry field starting at column 10, row 5:
+
-
: INPUT @(10,5),X
+
'''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 above entry field allows data entry up to 5 digits to the left of a decimal point and up to 3 digits to the right of a decimal point. The data entry space also permits a decimal point and minus sign, but no other characters.
+
-
Note: If an entry field is positioned on top of existing screen text, that text will appear inside the data entry space. This is a convenient way to add a default value to the INPUT statement.  
+
-
 
+
-
'''Multiple fields'''
+
   
   
-
The INPUT statement may include multiple fields, and will process them in the order listed, even if this order is not the customary left-to-right, top-to-bottom order of the items displayed on the screen. This feature lets the Internet Basic programmer create a "tab order" for the input screen.  
+
'''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.  
-
When entering data into a multi-field INPUT statement, the user presses Tab to move from field to field, and presses Enter to transmit the data to the program. See Example 2.  
+
'''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.  
-
See (Init Input Data) for information on how to display initial input values.
+
This information remains in the console's status buffer until a subsequent INPUT statement is executed.  
-
+
-
'''History:'''  This form of the INPUT statement was added to Comet98 in Build 266.  
+
-
The multi-field version, including the length override feature, was added in Comet98/Comet2000 Build 283.
+
To inquire on this field, perform the following operation:  
-
+
-
'''Example 1:'''  LENGTH 10  & LOCAL A$              ! Define variables
+
-
LENGTH 25  & LOCAL B$
+
VALUE = ASC(SUB(STS(0),8,1))
-
LENGTH 8.3 & LOCAL X
+
Note: VALUE is a numeric field with length/precision of 3.0.
-
LENGTH 3.0 & LOCAL Y
+
The following values are returned:
-
!
+
Value Key that caused the transmit to occur
 +
1 F10
 +
2 Enter (either key)
 +
3 Tab
-
PRINT (0) (EN);(CS)                ! Clear screen
 
-
!
 
-
PRINT "String field 1",@(0,10)     ! Display prompts
+
Additional values are returned when the (Easy Scan) mnemonic is invoked.
-
PRINT "Numeric field 1",@(0,12)
 
-
PRINT "String field 2",@(0,14)
+
'''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.
-
PRINT "Numeric field 2",@(0,16)
+
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:
-
INPUT @(17,10) A$                  ! Input fields
+
X = ASC(SUB(STS(0),9,1))
 +
Y = ASC(SUB(STS(0),10,1))  
-
INPUT @(17,12) X
+
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
-
PRINT "Default value",@(17,14)    ! Display default values
+
-
 
+
'''Example 2:'''  1000 FORMAT NAME$;ADDRESS$;CITY$;STATE:ZIP$
-
PRINT "99",@(17,16)
+
.
-
 
+
.
-
!
+
.
-
 
+
PRINT (0,500)     ! Formatted screen
-
INPUT @(17,14) B$                  ! Input fields
+
INPUT (0,1000)   ! Input items in FORMAT statement
-
 
+
-
INPUT @(17,16) Y
+
-
 
+
-
!
+
-
RUN "QMONITOR"
+
-
END
 
   
   
-
'''Example 2:'''  LENGTH 30 & LOCAL Company$, Addr1$,Addr2$
+
'''Example 3:'''  INPUT (0) A$;B$;C$
-
LENGTH 20 & LOCAL City$
+
(or)
-
 
+
-
LENGTH  2 & LOCAL State$
+
-
 
+
-
LENGTH  5 & LOCAL Zip$
+
-
 
+
-
LENGTH 5.0 & LOCAL NumEmployees
+
-
 
+
-
LENGTH 16.2 & LOCAL AnnualSales
+
 +
100 FORMAT A$;B$;C$
.
.
-
 
.
.
-
 
.
.
 +
INPUT (0,100)
-
  Input @(9,  5),Addr1$, 10; _
+
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).
-
      @(43, 5),NumEmployees, 4; _
+
-
      @(9,  8),State$, 15; _
+
-
      @(9,  6),Addr2$, 15; _
+
-
      @(9,  9),Zip$, 15; _
+
-
      @(9,  7),City$,  15; _
+
-
      @(43, 6),AnnualSales, 15
+
-
 
+
-
+
-
 
+
-
This INPUT statement creates 7 entry fields. The first parameter on each line above is the screen location of where each entry field will occur. The second parameter is the field name, and the third parameter is the length override for the entry field.
+
-
 
+
-
The "tab order" is Addr1$, NumEmployees, State$, Adr2$, Zip$, City$, and AnnualSales.
+

Revision as of 10:01, 20 May 2009


INPUT statement (legacy)

Syntax: INPUT [(lun)] variable-list [,EXCP=statement-label]

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).