Jumps to the specified label, but returns to the next opcode when the return opcode is encountered.
fade 500, 0 ; Fade out. gosub @FadeWait ; Wait until done with fading. fade 500, 1 ; Fade in again. gosub @FadeWait ... @FadeWait wait 0 if 0 !is_fading jf @FadeWait return
Subroutines can be compared to functions or procedures in other programming languages.
gosub is great way to keep your code small and easy to read, by putting blocks of code that you use multiple times in subs. Sometimes putting code that 'belongs together' (but is only used once) in a sub can also help to keep your code easy to read.
Unfortunately, gosub does not accept arguments the way create_thread does. If you want to pass arguments, you can still use local variables to do so, but you will have to manually set them every time before calling the subroutine.
You can gosub six levels deep, at max.