Action: Gosub(label ID)

Related Actions: gosubrandom, goto, gotorandom, repeat, exitloop, exitevent
Related Events: label
See also: FKiSS, Events, Actions

gosub(label ID)

First defined in: FKiSS3
Processing immediately jumps from this action to the specified label. When that label finishes, processing of the current event continues.

label ID

In FKiSS3, label ID may be a label ID number or a variable representing a label ID number.
In FKiSS4, label ID may be a label ID (number or symbolic name) or a variable representing a label ID number.

Example:

This example shows how a subroutine is created and called with the gosub() action. A subroutine can perform one or more actions and when done, processing continues with the action after the gosub() action.
; ... other actions in this event ...
;@ gosub(NextFrame) ; Advance to next frame of !MyAnimation group
; After the gosub(), processing continues from here.

... a bunch of actions or events can go here...

; Subroutine to advance to the next frame of a group, wrapping to the first frame.
;@ label(NextFrame)
;@   letframe(currentFrame, !MyAnimation)
;@   add(currentFrame, currentFrame, 1) ; Advance the frame by 1.
;@   mod(currentFrame, currentFrame, 4) ; Wrap to first frame when we reach frame 4.
;@   setframe(!MyAnimation, currentFrame)