GOSUB

GOSUB L

JUMPS TO THE SUBROUTINE WHICH BEGINS BY "L:"

  • Type: Command
  • Parameter: 1
  • Group: Reference

ACTION

The command GOSUB L forces the execution to jump to the subroutine called "L".

A subroutine is a group of statements which begins by a LABEL and ends with RETURN and which must be processed a certain number of times.

The subroutine ends by RETURN : when the keyword RETURN is executed, the execution of the main program resumes to the command immediately after the command GOSUB.

Remark: the name L must be defined by the keyword LABEL.

SYNTAX: GOSUB L

  • L : label

USE

  • The command GOSUB is used to execute a subroutine.

ERROR

  • If the label L does not exist.
  • If L is not a correct label name.

EXAMPLE

dim a,b

label addition

a=1:b=1

gosub addition

gosub addition

end

addition:

print a+b

print "done"

return

SEE ALSO

LABEL

RETURN