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

1-369 UniBasic Commands Reference A single-line statement that includes the INPUT command as a part of the THEN clause might not produce the results you expect. For example, the following statements produce no output: IF X = 1 THEN INPUT TEST ELSE PRINT "X NE 1" To correct this problem, enter each clause of the statement on a separate line, or use the IN() function to obtain input from theterminal or input queue. With null value handling turned on, a test on expr that is the null value returns false. For an overview of how the null value affects UniBasic, see Developing UniBasic Applications. Tip: You can nest IF/THEN/ELSE statements, but a CASE statement might be more efficient. Examples In the following example, the program statement tests if the variable SUPPLY is less than the variable DEMAND. If the comparison is true, program control is transferred to the statement labeled REORDER. IF SUPPLY < DEMAND THEN GOSUB REORDER In the next example, the program segment compares INCOME to TARGET. UniData executes the first branch if the comparison is true, or executes the second group of statements if the comparison is false. IF INCOME < TARGET THEN PRINT "Income less than target figure." END ELSE PRINT "Income equal to or greater than target!" END Related Commands UniBasic CASE, LOOP/REPEAT, NULL

IN Syntax IN( ) Description The UniBasic IN function captures raw data from an input queue or from a terminal. Tip: IN can capture function, arrow, and other special keys from the keyboard. Example In the following example, the program segment assigns the value y to ANSWER: DATA y ANSWER = IN() Related Commands UniBasic DATA, INPUT, INPUT @, INPUTTRAP, SYSTEM IN 1-370

1-369 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

A single-line statement that includes the INPUT command as a part of the<br />

THEN clause might not produce the results you expect. For example, the<br />

following statements produce no output:<br />

IF X = 1 THEN INPUT TEST ELSE PRINT "X NE 1"<br />

To correct this problem, enter each clause of the statement on a separate line,<br />

or use the IN() function to obtain input from theterminal or input queue.<br />

With null value handling turned on, a test on expr that is the null value returns false.<br />

For an overview of how the null value affects <strong>UniBasic</strong>, see Developing <strong>UniBasic</strong><br />

Applications.<br />

Tip: You can nest IF/THEN/ELSE statements, but a CASE statement might be more<br />

efficient.<br />

Examples<br />

In the following example, the program statement tests if the variable SUPPLY is less<br />

than the variable DEMAND. If the comparison is true, program control is transferred<br />

to the statement labeled REORDER.<br />

IF SUPPLY < DEMAND THEN GOSUB REORDER<br />

In the next example, the program segment compares INCOME to TARGET. UniData<br />

executes the first branch if the comparison is true, or executes the second group of<br />

statements if the comparison is false.<br />

IF INCOME < TARGET THEN<br />

PRINT "Income less than target figure."<br />

END ELSE<br />

PRINT "Income equal to or greater than target!"<br />

END<br />

Related <strong>Commands</strong><br />

<strong>UniBasic</strong><br />

CASE, LOOP/REPEAT, NULL

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

Saved successfully!

Ooh no, something went wrong!