Sharp OZ-707 Operation Manual - Page 97
ON expression GOSUB
UPC - 074000012141
View all Sharp OZ-707 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 97 highlights
ON ... GOSUB p FORMAT: ON expression GOSUB line number 1} {line number 2} { *Iabel 1 ' *Iabel 2 ,... Abbreviation: O. GOS. See Also: GOSUB, GOTO, ON...GOTO PURPOSE: Executes one of a set of subroutines, depending on the value of a control expression. REMARKS: When ON ... GOSUB is executed, the expression between ON and GOSUB is evaluated and reduced to an integer. If the value of the integer is 1, control is transferred to line number 1 or *label 1 in the list, as in a normal GOSUB. If the expression is 2, control is transferred to line number 2 or *Iabel 2 in the list, and so forth. Note: Be sure to place a space just before the GOSUB command. Otherwise it may be regarded as a variable. If the expression is zero, negative, or larger than the number of line numbers provided in the list, no subroutine is executed and execution proceeds with the next statement or line of the program. An error occurs if the value of the expression is -32769 or less or 32768 or more. Use commas (,) to separate line numbers or *Iabels in the list. EXAMPLE: 10: INPUT A 20: ON A GOSUB 100,200,300 30: END 100: PRINT "FIRST" 110: RETURN 200: PRINT "SECOND" 210: RETURN 300: PRINT "THIRD" 310: RETURN An entry of 1 displays "FIRST'; 2 displays ·SECOND"; 3 dIsplays "THIRD". Any other entry does not produce any display. 182 183