Accepts data entered by the user at a terminal.
INPUT input_var[MAXLEN=nn][prompt] [TYPE={CHAR|TEXT|NUMBER|INTEGER|DATE}] [STATUS=num_var][NOPROMPT][BATCH-MODE] [FORMAT={txt_lit|_var|_col}]
Text, numeric, or date variable for the input data.
Prompt (literal not variable) displayed to the user.
Datatype required for the input.
Numeric variable for a return status code.
Prevents the prompt from displaying before INPUT is processed.
If BATCH-MODE is specified and no more arguments are in the command line, a value of 3 is returned in the STATUS variable and the user is not prompted for input.
Format for entering a date (see Table 57, Date Edit Format Characters).
Use MAXLEN to prevent entering data that is too long. If INSERT or UPDATE references a variable whose length is greater than that defined in the database, the SQL is rejected and Production Reporting halts. If the maximum length is exceeded, the terminal beeps (on some systems, this may cause the screen to flash instead).
If prompt is omitted, Production Reporting uses the default prompt, Enter [$|#]var:. In any case, a colon (:) and two spaces are added to the prompt.
Specifying TYPE causes data type checking to occur. If the string entered is not the type specified, the terminal beeps and an error message is displayed. INPUT is then re-executed. If TYPE=DATE is specified, then input_var can be a date or text variable; however, TYPE=DATE is optional if input_var is a date variable. If a numeric variable is used, it is validated as a numeric variable. CHAR, TEXT, and DATE are invalid types.
Table 43. Data Types Supported by INPUT
A floating point number in the format [+|-]9999.999[E[+|-]99] | |
Specifying STATUS causes INPUT to complete regardless of what the user enters. No error message is displayed. A nonzero error code is stored in the indicated numeric variable if the length or datatype entered is incorrect.
Table 44. Values of the STATUS Argument of the INPUT Command
Too long (longer than MAXLEN or the input for an INTEGER variable is < -2147483648 or > +2147483647). | |
No arguments remain on the command line. The command was ignored. |
By using NOPROMPT and STATUS with SHOW, you can write a sophisticated data entry routine.
FORMAT can only be used with dates. It can be a date edit mask or the keyword DATE. Use the keyword DATE if the date must be in the format as specified with INPUT-DATE-EDIT-MASK for the current locale. If FORMAT has not been set, use a database-independent format for the data in Table 43, Data Types Supported by INPUT.
The following example shows several INPUT commands:
input $state maxlen=2 'Please enter state abbreviation' input #age 'Enter lower age boundary' type=integer input $start_date 'Enter starting date for report' type=date input $date_in format='Mon dd yyyy' input $date format=date
The following example shows another INPUT command:
show clear-screen (5,32) reverse 'CUSTOMER SUMMARY' normal Try_again: show (12,20) 'Enter Start Date: ' clear-line input $start-date noprompt status=#istat type=date if #istat != 0 show (24,1) 'Please enter date in format DD-MON-YY' beep goto try_again end-if show (24,1) clear-line! Clear error message line.
The following example illustrates the use of BATCH-MODE:
begin-program while (1) input $A status=#stat batch-mode if #stat = 3 break else do procedure ($a) end-if end-while end-program
The INPUT‑DATE‑EDIT‑MASK setting in SQR.INI.