![QRP Labs U4B Ultimate4 Скачать руководство пользователя страница 36](http://html1.mh-extra.com/html/qrp-labs/u4b-ultimate4/u4b-ultimate4_operating-manual_3285244036.webp)
GOSUB causes program execution to jump the subroutine at the specified line number. When the
computer encounters the RETURN statement, it jumps back to the line following the one in was
called from.
Line numbers are not necessary in QDOS BASIC. However if you want it to be possible to call a
subroutine located at a particular line of code, then you must use a (unique) line number on that
line, so that the GOTO statement can find it.
For example:
LET A = 1
GOSUB 100
LET A = 2
GOSUB 100
END
100 PRINT A + 4
RETURN
Running this program sets variable A to 1, then calls the subroutine at line 100; then it sets
variable A to 2 and calls the subroutine again. Finally the END statement stops execution. The
result printed on the terminal is:
5
6
Note that you can also make nested calls to other subroutines from within subroutines. But only 4
levels of nested subroutine calls are possible.
4.8.5 END
Ends the program.
Syntax:
END
For example:
LET A = 1
END
The first line is executed, which sets variable A to 1. Then the program is ended.
Note that if the computer runs out of program lines to execute, it ends automatically. This has
already been seen in the examples in the previous section. Therefore END is not necessary as the
last line in a program. But it can still be useful sometimes in the middle of a program if you want to
END on a certain condition, or if there are subroutines following after the main program block.
U4B operating manual Rev 1.00
36
Содержание U4B Ultimate4
Страница 54: ...U4B operating manual Rev 1 00 54...