qb45advr.hlp (
Topic list)
ON...GOSUB Statement Programming Example
◄QuickSCREEN► ◄Details► ◄Example► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
ON...GOSUB Statement Programming Example
This example causes program control to branch to one of three
subroutines, depending on the value of Chval:
CLS ' Clear screen
Attend = 20
Fees = 5 * Attend
PRINT "1 Display attendance at workshops"
PRINT "2 Calculate total registration fees paid"
PRINT "3 End program"
PRINT : PRINT "What is your choice?"
Choice:
DO
ch$ = INKEY$
LOOP WHILE ch$ = ""
Chval = VAL(ch$)
IF Chval > 0 AND Chval < 4 THEN
ON Chval GOSUB Shop, Fees, Progend
END IF
END
Shop:
PRINT "ATTENDANCE IS", Attend
RETURN Choice
Fees:
PRINT "REGISTRATION FEES ARE $"; Fees
RETURN Choice
Progend:
END