UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

Warning: Processing differs when you include INPUT within a single-line IF/THEN/ELSE statement, which is illustrated by the following program segment: RESP = 5 IF RESP = 10 THEN INPUT TEST ELSE PRINT "NO INPUT" END This program produces no output because UniData interprets the ELSE as being a part of the INPUT statement, even though no WAITING clause is included. To avoid this, place the INPUT statement on its own line, as shown in the following example: RESP = 5 IF RESP = 10 THEN INPUT TEST END ELSE PRINT "NO INPUT" END Parameters The following table describes each parameter of the syntax. Parameter Description 1-383 UniBasic Commands Reference var Specifies a variable to receive the input. In the first form, if data (received by a DATA statement) is present in an input queue, INPUT assigns the next value to the variable var. If a DATA statement was not executed, INPUT prompts the user for input by displaying a question mark on the terminal. ,length Specifies the maximum number of characters accepted. _ UniData waits for the user to press ENTER before processing data input at the keyboard. If the underscore is not included, UniData stops accepting input when the user enters the maximum number of characters. Use the underscore parameter to allow the user to backspace after entering the maximum number of characters. For example, if you specify “INPUT X,5_”, the user can backspace to modify the entry after entering five characters. INPUT Parameters

Parameter Description : Normally, when a user types something and presses ENTER in response to an INPUT statement, UniData issues a line feed. The : parameter inhibits this line feed. ,-l UniData checks the type-ahead buffer. The following values are returned in var: 1 – Data is present in the buffer. 0 – No data is present in the type-ahead buffer. Use the -1 parameter to periodically check for input in an application that runs continuously. FOR | WAITING time.expr Examples In the following example, the program segment reads the first value established by the DATA statement and assigns it to the variable TEST. In this case, the value 10 is read. DATA 10,20,30,40,50 INPUT TEST Specifies the length of time to wait for input. If you do not enter the input before the wait period expires, var does not change, and the ELSE clause executes. If no ELSE nor THEN clause exists, the session terminates at the end of the wait period. UNFILTERED Sets INPUT to capture raw characters (such as backspace, up arrow, down arrow, or ENTER) from the keyboard. THEN statements ELSE statements Specifies statements to execute when input is received within the time specified in the FOR | WAITING clause and input is not an empty string. Specifies statements to execute if no input is received by the time specified in the FOR | WAITING clause or if the input is an empty string. INPUT Parameters (continued) In the next example, the program statement prints the prompt “Enter name:”. The INPUT statement then enables the user to enter any number of characters, stopping only when the user presses ENTER. The first 10 characters the user enters are assigned to the variable NAME. PRINT "Enter name: "; INPUT NAME,10_ INPUT 1-384

Parameter Description<br />

: Normally, when a user types something and presses ENTER in response<br />

to an INPUT statement, UniData issues a line feed. The : parameter<br />

inhibits this line feed.<br />

,-l UniData checks the type-ahead buffer. The following values are returned<br />

in var:<br />

1 – Data is present in the buffer.<br />

0 – No data is present in the type-ahead buffer.<br />

Use the -1 parameter to periodically check for input in an application that<br />

runs continuously.<br />

FOR |<br />

WAITING<br />

time.expr<br />

Examples<br />

In the following example, the program segment reads the first value established by<br />

the DATA statement and assigns it to the variable TEST. In this case, the value 10 is<br />

read.<br />

DATA 10,20,30,40,50<br />

INPUT TEST<br />

Specifies the length of time to wait for input. If you do not enter the input<br />

before the wait period expires, var does not change, and the ELSE clause<br />

executes. If no ELSE nor THEN clause exists, the session terminates at<br />

the end of the wait period.<br />

UNFILTERED Sets INPUT to capture raw characters (such as backspace, up arrow,<br />

down arrow, or ENTER) from the keyboard.<br />

THEN<br />

statements<br />

ELSE<br />

statements<br />

Specifies statements to execute when input is received within the time<br />

specified in the FOR | WAITING clause and input is not an empty string.<br />

Specifies statements to execute if no input is received by the time<br />

specified in the FOR | WAITING clause or if the input is an empty string.<br />

INPUT Parameters (continued)<br />

In the next example, the program statement prints the prompt “Enter name:”. The<br />

INPUT statement then enables the user to enter any number of characters, stopping<br />

only when the user presses ENTER. The first 10 characters the user enters are<br />

assigned to the variable NAME.<br />

PRINT "Enter name: "; INPUT NAME,10_<br />

INPUT 1-384

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!