User Tools

Site Tools


k10:k10.5:k10.5.8:start

10.5.8 On GoSub

The 'On GoSub' statement exists in Gambas since version 3.2.

10.5.8.1' On GoSub' syntax

Jumps to one of the calculated labels. The evaluation of 'Expression' must result in an integer value to select a (target) label. If there is a return statement in the instructions after the target(-Label), the program returns to execute the code immediately after the 'On GoSub' statement.

On Expression GoSub Label_0 [ , Label_1 ... ]
Instruction(s) -> program continuation after RETURN

Label_0:
  Instruction(s)_0
  RETURN
Label_1:
  Instruction(s)_1
  RETURN
…

10.5.8.2 Notes on the syntax

  • If the expression results in 0, then the first label is selected, if the expression has the value 1, then the second label is selected and so on…. .
  • If the expression is negative or equal to or greater than the number of labels, then the 'On GoSub' instruction is tacitly ignored.
  • To return to Label_x: after the instructions under the calculated target(-Label) Label_x: to *, you must use the Return statement - standing alone on one line.

Download

Articles

Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k10/k10.5/k10.5.8/start.txt · Last modified: 23.09.2023 by honsek

Page Tools