Goto
From Scriptwiki
The /goto command allows you to jump from one point in a script to another point.
/goto <label>
Note: Using a goto incorrectly could lead to an infinite loop. You can break out of a currently running script by pressing Control+Break.
You can also use a variable as a goto name, eg.
:%jumppoint
If %jumppoint were set to 5, /goto 5 would jump to that point in the script.
Example
/number { if ($1 == 1) goto one elseif ($1 == 2) goto two else goto unknown :one echo One halt :two echo Two halt :unknown echo Unknown number! halt }
In the above alias, if the first parameter were 1, it would jump to label one, otherwise if it were 2 it would jump to label two. If it is none of those, it will jump to the unknown label.
/randpoint { var %jump1 = 1, %jump2 = 2 goto $r(1,2) :%jump1 echo Picked jump 1! halt :%jump2 echo Picked jump 2! halt }
The above alias is an example of using a variable as a point name. It will pick either point 1 or 2.