# GOSUB

Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)

Tags: gosubstackdepth

# Description

The GOSUB statement causes execution of a local subroutine, after which execution will continue with the next line of code.

GOSUB label
1

Where label refers to an existing label within the current source code.

# Notes

The compiler does not check for the existence of a RETURN statement and if no RETURN statement is encountered the program will continue until the final statement and not return to the original GOSUB.

An example of use is as:

GOSUB Initialize ;* open files etc..
GOSUB Main ;* perform main program
GOSUB Finish ;* close files etc..
STOP
...
Initialize: * open files
OPEN......
.
RETURN
....
Main: * main execution loop
......
RETURN
Finish: * clean up after execution
......
RETURN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Go back to jBASE BASIC

Go back to Programmers' Reference Guide