Positron Compiler Documentation

Gosub

Positron16 · Revision 1.1.3.5 · PDF page 337

Gosub Label

Gosub jumps the program to a defined label and continues execution from there. Once the program hits a Return command the program returns to the instruction following the Gosub that called it and continues execution from that point.

Label is a user-defined label.

' Implement a standard subroutine call
  GoTo Main        ' Jump over the subroutines
SubA:
  subroutine A code
  ……
  ……
  Return

SubB:
  subroutine B code
  ……
  ……
  Return

' Actual start of the main program
Main:
  Gosub SubA
  Gosub SubB

A subroutine must always end with a Return command.

View original PDF page 337Open page in PDFOriginal PDF page 337