Skip to content

Goto

goto {label}

Also searchable as: Goto

goto makes the script go on at the line after a label.

Parameter Meaning
label Name of the label, with or without the trailing :. Case does not matter.

goto looks for the label starting from its own line, one line further each step, forward and backward at the same time, and takes the first match. At equal distance the forward one wins. So if a label name is used twice, the nearest one is chosen, not the first one in the script.

When no label matches, nothing happens and the script goes on with the next line.

loop:
if %done
goto finished
gosub work
goto loop
finished:
display ok Done after %rounds rounds.
halt
sub work
set %rounds %rounds + 1
if %rounds = 3
set %done #true
return

A switch built from labels. The comma glues case and the number into one label name:

set %a #random % 3 + 1
goto case , %a
case1:
display ok One
goto case_end
case2:
display ok Two
goto case_end
case3:
display ok Three
case_end:
halt

See also

Based on the EasyUO wiki, edited for EasyUO Reforged. This text is available under the GNU Free Documentation License 1.2.