GoTo: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
GOTO line-num | label


The '''GoTo''' [[statement]] transfers program control to a specified line number or label. The GOTO statement not be executed from the command line. Error 1011 (Illegal immediate statement) will occur if such usage is attempted.
The '''GoTo''' [[statement]] transfers program control to a specified line number or label.  


====Comments and Examples====
The GOTO statement not be executed from the command line. Error [[1011]] (Illegal immediate statement) will occur if such usage is attempted.  Instead try [[go]] [[line number]].
 
===Syntax===
GOTO <[[line ref]]>
 
[[file:goto.png|300px]]
 
===Comments and Examples===


In the following example, line 320 transfers control to line number 45:
In the following example, line 320 transfers control to line number 45:
Line 9: Line 15:
  00045 start: !
  00045 start: !
  00050 let a = 1
  00050 let a = 1
  00060 let  
  00060 let a += 1
  00320 GOTO 45
  00320 GOTO 45


Line 16: Line 22:
  00045 start: !
  00045 start: !
  00050 let a = 1
  00050 let a = 1
  00060 let  
  00060 let a += 1
  00320 GOTO start
  00320 GOTO start


====Parameters====
===Parameters===


GOTO has one required parameter: '''line-num''' or '''label'''. This is the line number or label that program control is to be transferred to.
GOTO has one required parameter: the [[Line=ref]] can be either a '''line number''' or '''label'''. This is the line number or label that program control is to be transferred to.


====Technical considerations====
===Technical considerations===


# See the ON GOTO statement for a method of branching to one of several lines depending on the value of a numeric expression.
# See the ON GOTO statement for a method of branching to one of several lines depending on the value of a numeric expression.
Line 30: Line 36:
[[Category:Statements]]
[[Category:Statements]]
[[Category:Control Structures]]
[[Category:Control Structures]]
[[Category:Branching Statements]]
</noinclude>
</noinclude>

Latest revision as of 21:18, 7 April 2018

The GoTo statement transfers program control to a specified line number or label.

The GOTO statement not be executed from the command line. Error 1011 (Illegal immediate statement) will occur if such usage is attempted. Instead try go line number.

Syntax

GOTO <line ref>

Comments and Examples

In the following example, line 320 transfers control to line number 45:

00045 start: !
00050 let a = 1
00060 let a += 1
00320 GOTO 45

The above example could be rewritten to use a label instead of a line number to transfer control. In the next example, where the GOTO points to a line label, control is transferred to the first executable statement after the label:

00045 start: !
00050 let a = 1
00060 let a += 1
00320 GOTO start

Parameters

GOTO has one required parameter: the Line=ref can be either a line number or label. This is the line number or label that program control is to be transferred to.

Technical considerations

  1. See the ON GOTO statement for a method of branching to one of several lines depending on the value of a numeric expression.