11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Parameters<br />

The following table describes each parameter of the syntax.<br />

Parameter Description<br />

expr Specifies a numeric expression. UniData evaluates the expression, and then<br />

truncates it to an integer. Control passes to a subroutine based on the<br />

following rules.<br />

If expr is less than or equal to 1, UniData transfers program control to the<br />

subroutine starting at the first label in the list. If the number is 2, UniData<br />

transfers control to the subroutine starting at the second label, and so forth.<br />

If expr is higher than the number of labels, UniData transfers control to the<br />

last label in the list.<br />

If expr is nonnumeric, control transfers to the first label.<br />

label Specifies a subroutine label or multiple subroutine labels.<br />

: Optional. A colon is required to identify a nonnumeric label in the statement<br />

label itself only, not in the reference to it in the ON/GOSUB statement.<br />

ON/GOSUB Parameters<br />

Examples<br />

In the following example, the program segment divides the variable BALANCE by<br />

100. If the result is less than or equal to 1, the program transfers control to subroutine<br />

U100. If the value is 2 or 3, it transfers control to U200 or U300 respectively. If the<br />

value is greater than or equal to 4, UniData transfers control to subroutine U400.<br />

ON BALANCE/100 GOSUB U100,U200,U300,U400<br />

In the next example, the program segment transfers control to a subroutine after<br />

prompting the user for a screen item to modify. In this case, depending on the number<br />

the user enters, UniData transfers control to one of the five subroutines in the<br />

GOSUB clause. If the user response is nonnumeric or less than 1, UniData transfers<br />

control to the first subroutine. If the user enters a value greater than 5, UniData<br />

transfers control to the last subroutine (500).<br />

GOSUB DISPLAY.SCREEN:<br />

PRINT "Enter Item number to modify (1-5): ":<br />

INPUT ACTION<br />

ON ACTION GOSUB 100,200,300,400,500<br />

ON/GOSUB 1-530

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

Saved successfully!

Ooh no, something went wrong!