IB Statements/input

From CometWiki

(Difference between revisions)
Jump to: navigation, search
(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...)
Line 114: Line 114:
.
.
-
Input @(9,  5),Addr1$, 10; _
+
  Input @(9,  5),Addr1$, 10; _
       @(43, 5),NumEmployees, 4; _
       @(43, 5),NumEmployees, 4; _
       @(9,  8),State$, 15; _
       @(9,  8),State$, 15; _

Revision as of 09:54, 20 May 2009

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

length-override = the size of the entry area (number of characters)

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:

The entry field is created automatically by Comet

It does not require transmit marks

The field type and length/precision are validated by Comet

It supports multiple entry fields and a specified "tab order"

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:

INPUT @(20,12),A$

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.) For example:

INPUT @(20,12),A$,5

In this case, the entry field will be 5 characters, even though the declared length of the field is 10 bytes. 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

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.

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.

See (Init Input Data) for information on how to display initial input values.

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.

Example 1: LENGTH 10 & LOCAL A$  ! Define variables

LENGTH 25 & LOCAL B$

LENGTH 8.3 & LOCAL X

LENGTH 3.0 & LOCAL Y

!

PRINT (0) (EN);(CS)  ! Clear screen

!

PRINT "String field 1",@(0,10)  ! Display prompts

PRINT "Numeric field 1",@(0,12)

PRINT "String field 2",@(0,14)

PRINT "Numeric field 2",@(0,16)

!

INPUT @(17,10) A$  ! Input fields

INPUT @(17,12) X

!

PRINT "Default value",@(17,14)  ! Display default values

PRINT "99",@(17,16)

!

INPUT @(17,14) B$  ! Input fields

INPUT @(17,16) Y

! RUN "QMONITOR"

END

Example 2: LENGTH 30 & LOCAL Company$, Addr1$,Addr2$

LENGTH 20 & LOCAL City$

LENGTH 2 & LOCAL State$

LENGTH 5 & LOCAL Zip$

LENGTH 5.0 & LOCAL NumEmployees

LENGTH 16.2 & LOCAL AnnualSales

.

.

.

 Input @(9,  5),Addr1$, 10; _
     @(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.