Input

From Br Wiki
Jump to: navigation, search

The Input (IN) statement assigns a value to a variable from the keyboard, a procedure file (when RUN PROC is in effect), a display file, a communications file, or a window file.

See also Input (disambiguation)

Comments and Examples

The INPUT statement can be used with a file number of zero (i.e., #0) or without any file number to accept data from the keyboard. The status line contains the word "INPUT" to signal the operator that the program is awaiting data entry from the keyboard. The INPUT statement may be used to accept string or numeric data, or a mixture of both. Multiple items being entered at the same time must be separated by commas.

For example, to accept a name and date, a program could have the following lines:

00100 PRINT "Enter NAME"
00110 INPUT NAME$
00120 PRINT "Enter date: MM, DD, YY"
00130 INPUT MO,DAY,YR

Since three items are being entered together in line 130, the operator must separate these three numbers with commas.

Syntax

INPUT [*<file number>|<window number>:] {MAT< array name>|<variable name>,} [{<error condition> <line ref>,}]

Input.png

Defaults

  1. Accept input from the keyboard or procedure file.
  2. Interrupt the program if an error occurs and "ON error" is not active.

Parameters

When used, the optional "wind-num" or "file-num" parameters indicate that the information to be input is to come from a file or window that has already been opened by an OPEN statement. An integer or numeric expression must be used for this parameter.

The "variable name" and "MAT array-name" parameters represent the list of variables to be assigned values. If more than one variable or array name is used, they must be separated by commas.

INPUT allows error processing with the optional "error-cond line-ref" parameter (see Error Conditions for more information). Control characters are no longer allowed as valid input for INPUT statements.

Technical Considerations

  1. ) Relevant error conditions are: CONV, EOF, ERROR, Exit, HELP, IOERR, and SOFLOW.
  2. ) For processing an entire record, LINPUT is preferred to INPUT unless the fields in the input data are separated by commas.
  3. ) When used with a display file, INPUT assigns values to variables as if the data were being typed in at the keyboard. When multiple items are being INPUT in one statement, the record in the display file must include the correct number of items and each item must be separated from the others by commas.
  4. ) After each variable has been assigned a value, INPUT ignores any extra values remaining in the input record.
  5. ) When a program is loaded from a procedure file and started with the command RUN PROC, all INPUT statements which normally receive input from the keyboard are instructed to take their input from the next records of the procedure file.
  6. ) When OPTION INVP is in effect, commas (not periods) must be entered as decimal points to support European-style numbers. See the OPTION statement for details.
  7. ) INPUT should not be used with EOL=NONE for display files (or communications files); LINPUT should be used instead, as it will read characters until the maximum string length is reached.
  8. ) When merely waiting for any operator response, use LINPUT A$ instead of INPUT A$ to avoid error code 0501 (no data was entered).
  9. ) Business Rules buffers keyboard characters so that they are not lost between INPUT statements. All keyboard characters (up to 128) will be forwarded to either INPUT or KSTAT$. Ctrl-A clears the buffer of any characters ahead of it and is recognized immediately even if other keystrokes are buffered ahead of it. Unless ON FNKEY IGNORE or ON HELP IGNORE are active, the function keys and <HELP> key will also be recognized immediately and other characters in the buffer will be dropped.
  10. ) The BRConfig.sys TYPEAHEAD specification may be used to turn keyboard buffering on or off.
  11. ) Numbers with exponents may be entered during INPUT statement processing. Examples are 5.2E3 (=5200), -5.2e+3 (-520), and +5e-4 (=.0005).
  12. ) Keyboard input for INPUT statements with multiple variables may be terminated without causing an error when a forward slash (/) is typed as the last input character. The slash is not read into the variable, and variables not read are not modified, so default values may be used for them. This also applies to input with RUN PROC and to display files.
  13. ) Control characters are no longer allowed as valid input for INPUT statements on Unix, Linux and AIX versions of Business Rules. Some of the characters (such as Ctrl-S) were previously being accepted as valid input, but when that data was sent to the printer, the printer would go off-line. Also, since most terminals cannot display control characters, the input would show up as a space, making it difficult to spot the problem.
  14. ) The WAIT= parameter and TIMEOUT error trap may now be used with INPUT/RINPUT statements to force releasing of records. This feature is useful for multi-user situations.
    1. .) WAIT= specifies the number of seconds the system should wait for operator input before responding with a TIMEOUT error condition.
    2. .) NOTE that WAIT=0 instructs the system to wait for zero seconds, not to ignore the WAIT instruction.
    3. .) Also, -1 is a special WAIT value that instructs the system to wait forever, if necessary. Every time the operator presses any key, the clock is reset for WAIT seconds.
00100 INPUT WAIT=10:X$ TIMEOUT 100
00110 RINPUT WAIT=10:X$ TIMEOUT 100
00120 LINPUT WAIT=10:X$ TIMEOUT 100
00130 INPUT FIELDS "10,10,C 10", WAIT=10:X$ TIMEOUT 100
00140 INPUT #11,FIELDS "10,10,C 10", WAIT=10:X$ TIMEOUT 100
00150 RINPUT FIELDS "10,10,C 10",WAIT=10:X$ TIMEOUT 100
00160 INPUT SELECT "10,10,C 10",WAIT=10:X$ TIMEOUT 100
00170 RINPUT #11,SELECT "10,10,C 10",WAIT=10:X$ TIMEOUT 100

The TIMEOUT error condition traps time-out errors (error code 4145) and specifies the line number of an appropriate error-handling routine.

00100 RELEASE #ITEM:
00110 PRINT "OVER TIME LIMIT"
00120 PRINT "Your hold on inventory items has expired, re-enter order."

Before releasing the record, you may want to go to a routine that warns with a message and a few beeps that the hold on records is about to be released, then gives the operator an opportunity to continue data entry.

Also see "KSTAT$" function for information on how to use the WAIT parameter with that function.

See also LINPUT.