Gosub
From Wiki
Synopsis
gosub {sub name} {param1, param2, ...}
Description
The gosub command transfers the execution to a sub with the name given by the parameter.
Parameters can be added after the sub name. They will be transfered in the variables %1, %2, and so on. The variable %0 holds the number of parameters passed.
Note: | You must not jump out of a sub! Use return to properly terminate a sub routine. To prevent a stack overflow, EUO only supports 1000 consecutive GoSubs without returning. Remember this when using recursion! When the GoSub stack is about to get 1001 levels, the very first level in the bottom of the stack is deleted to make room. |
Example 1
gosub s7IsGreaterThan CEO RK ; %1 = CEO ; %2 = RK ; %0 = 2 sub s7IsGreaterThan display ok %1 && %2 even %0 , gether < una return
Example 2
; syntax = ; gosub {subName} [parameters...] gosub example_goSub These are the parameters sub example_goSub ; %0 = 4 ; %1 = These ; %2 = are ; %3 = the ; %4 = parameters set %message for %_cnt 1 %0 { set %message %message , % . %_cnt , #spc } display ok %message halt
Related Commands
Sub | Return |
See Also
Flow Control
- Flow control commands allow scripts to make decisions based on the evaluation of boolean expressions.
break | Jumps to first statement outside of loop |
call | Transfers execution to another script file |
continue | Jumps execution of a loop to next iteration |
exit | Exits a called script |
for | Creates a counting loop |
gosub | Transfers execution to the matching sub |
goto | Jumps to another part of the script given by a label |
halt | Stops the script |
if | Executes code based on the evaluation of an expression |
pause | Temporarily stops the execution of the current script |
repeat..until | Creates a loop that checks condition after execution |
return | Returns from a sub |
stop | Ends the script |
while | Creates a loop that checks condition before execution |