Difference between revisions of "Goto"
From Wiki
Cannedboot (Talk | contribs) (added 'switch' snippet) |
|||
| Line 1: | Line 1: | ||
{{command header|Flow Control}} | {{command header|Flow Control}} | ||
| − | {{body|goto {label | + | {{body|goto {label}|The ''goto'' command moves the execution to another part of the script. The destination point is given by a label.}} |
| Line 19: | Line 19: | ||
exit: | exit: | ||
</pre> | </pre> | ||
| + | |||
| + | ==== Simulating a Switch Statement ==== | ||
| + | |||
| + | Switch structures (like seen in C/C++) can be simulated in EasyUO using the goto statement: | ||
| + | |||
| + | <pre> | ||
| + | set %a #random % 3 + 1 | ||
| + | goto case , %a | ||
| + | |||
| + | case1: | ||
| + | display ok One | ||
| + | goto case_exit | ||
| + | |||
| + | case2: | ||
| + | display ok Two | ||
| + | goto case_exit | ||
| + | |||
| + | case3: | ||
| + | display ok Three | ||
| + | goto case_exit | ||
| + | |||
| + | case_exit: | ||
| + | halt</pre> | ||
{{footer}} | {{footer}} | ||
Revision as of 17:33, 14 October 2005
Synopsis
goto {label}
Description
The goto command moves the execution to another part of the script. The destination point is given by a label.
| Note: |
Example
loop: if %donotloop goto exit goto loop exit:
Simulating a Switch Statement
Switch structures (like seen in C/C++) can be simulated in EasyUO using the goto statement:
set %a #random % 3 + 1 goto case , %a case1: display ok One goto case_exit case2: display ok Two goto case_exit case3: display ok Three goto case_exit case_exit: halt
See also
| Main Page | Documentation |