Difference between revisions of "MC-Basic:GOTO"
(Created page with '{{MC-Basic |SHORT FORM= |SYNTAX= GOTO ''<program label><br> <br> <program lable>:'' |AVAILABILITY= All versions |DESCRIPTION= The GOTO statement is used to perform an uncon…') |
m |
||
(10 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
|SYNTAX= | |SYNTAX= | ||
− | GOTO '' | + | GOTO <''program label''> |
− | |||
− | <program | + | <''program label''>: |
|AVAILABILITY= | |AVAILABILITY= | ||
Line 13: | Line 12: | ||
|DESCRIPTION= | |DESCRIPTION= | ||
− | The GOTO statement is used to perform an unconditional branch to another section of code. It references a label that must appear in the code. Labels are written as a name followed by a colon. Labels must appear on their own lines and they may be commented. You can only branch within a program, event, function, or subroutine. The GOTO statement and the label must be within the same program block. The GOTO statement can be compared to the conditional branching statements, IF..THEN and SELECT CASE. | + | The GOTO statement is used to perform an unconditional branch to another section of code. |
+ | It references a label that must appear in the code. | ||
+ | |||
+ | Labels are written as a name followed by a colon. | ||
+ | Labels must appear on their own lines and they may be commented. | ||
+ | |||
+ | You can only branch within a program, event, function, or subroutine. | ||
+ | The GOTO statement and the label must be within the same program block. | ||
+ | The GOTO statement can be compared to the conditional branching statements, IF..THEN and SELECT CASE. | ||
|TYPE= | |TYPE= | ||
Line 31: | Line 38: | ||
|LIMITATIONS= | |LIMITATIONS= | ||
− | Write | + | * Write only. |
− | + | * The label must appear on a line of its own. | |
− | FUNCTION…END FUNCTION, and ONEVENT…END ONEVENT). | + | * Labels may not be repeated within a task. |
+ | *A GOTO branch must reference a label within the same program block (PROGRAM…END PROGRAM, SUB…END SUB, FUNCTION…END FUNCTION, and ONEVENT…END ONEVENT). | ||
|EXAMPLE= | |EXAMPLE= | ||
− | + | <pre> | |
− | + | Program | |
− | GOTO Reference1 | + | <nowiki><code></nowiki> |
− | + | GOTO Reference1 | |
+ | <nowiki><code></nowiki> | ||
− | Reference1: | + | Reference1: |
− | + | <nowiki><code to be executed after GOTO></nowiki> | |
End Program | End Program | ||
+ | </pre> | ||
|SEE ALSO= | |SEE ALSO= | ||
− | * [[ | + | * [[MC-Basic:IF ... THEN ... ELSE|IF ... THEN ... ELSE]] |
− | * [[ | + | * [[MC-Basic:PROGRAM ... END PROGRAM|PROGRAM ... END PROGRAM]] |
− | * [[ | + | * [[MC-Basic:SELECT ... CASE|SELECT ... CASE]] |
− | * [[ | + | * [[MC-Basic:SUB ... END SUB|SUB ... END SUB]] |
+ | |||
+ | [[Category:MC-Basic:Flow Control Statements|GOTO]] | ||
}} | }} |
Latest revision as of 07:01, 29 October 2014
The GOTO statement is used to perform an unconditional branch to another section of code. It references a label that must appear in the code.
Labels are written as a name followed by a colon. Labels must appear on their own lines and they may be commented.
You can only branch within a program, event, function, or subroutine. The GOTO statement and the label must be within the same program block. The GOTO statement can be compared to the conditional branching statements, IF..THEN and SELECT CASE.
Syntax
GOTO <program label>
<program label>:
Availability
All versions
Scope
Task
Limitations
- Write only.
- The label must appear on a line of its own.
- Labels may not be repeated within a task.
- A GOTO branch must reference a label within the same program block (PROGRAM…END PROGRAM, SUB…END SUB, FUNCTION…END FUNCTION, and ONEVENT…END ONEVENT).
Examples
Program <code> GOTO Reference1 <code> Reference1: <code to be executed after GOTO> End Program