Jump anywhere: Difference between revisions
m
→{{header|TXR}}: Fixed unfinished </code> tag
(Added Chipmunk Basic, GW-BASIC, True BASIC, Quite BASIC, Minimal BASIC and MSX Basic.) |
m (→{{header|TXR}}: Fixed unfinished </code> tag) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 533:
300 GOTO : REM NO LINE NUMBER, JUMPS TO LINE 0</syntaxhighlight>
<syntaxhighlight lang="applesoftbasic">CONT : REM CONTINUE, JUMP BACK TO WHERE THE PROGRAM STOPPED</syntaxhighlight>
==={{header|BASIC256}}===
BASIC256 supports both <code>goto</code> and <code>gosub</code>.▼
{{works with|QBasic}}▼
{{works with|Yabasic}}▼
<syntaxhighlight lang="freebasic">print "First line."▼
gosub sub1▼
print "Fifth line."▼
goto Ending▼
sub1:▼
print "Second line."▼
gosub sub2▼
print "Fourth line."▼
return▼
Ending:▼
print "We're just about done..."▼
goto Finished▼
sub2:▼
print "Third line."▼
return▼
Finished:▼
print "... with goto and gosub, thankfully."▼
end</syntaxhighlight>▼
{{out}}▼
<pre>Igual que la entrada de FutureBasic.</pre>▼
==={{header|Chipmunk Basic}}===
Line 561 ⟶ 590:
==={{header|GW-BASIC}}===
GW-BASIC supports both <code>goto</code> and <code>gosub</code>.
{{works with|Applesoft BASIC}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
Line 647 ⟶ 678:
<pre>Same as FutureBasic entry.</pre>
==={{
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
▲BASIC256 supports both <code>goto</code> and <code>gosub</code>.
▲{{works with|QBasic}}
▲{{works with|Yabasic}}
▲<syntaxhighlight lang="freebasic">print "First line."
▲gosub sub1
▲print "Fifth line."
▲goto Ending
▲sub1:
▲print "Second line."
▲gosub sub2
▲print "Fourth line."
▲return
▲Ending:
▲print "We're just about done..."
▲goto Finished
▲sub2:
▲print "Third line."
▲return
▲Finished:
▲print "... with goto and gosub, thankfully."
▲end</syntaxhighlight>
▲{{out}}
▲<pre>Igual que la entrada de FutureBasic.</pre>
=={{header|BQN}}==
Line 906 ⟶ 911:
=={{header|COBOL}}==
<syntaxhighlight lang="
PROGRAM-ID.
* Nobody writes like this, of course; but...
PROCEDURE DIVISION.
* You can jump anywhere you like.
start-paragraph.
GO TO
yet-another-paragraph.
ALTER
* That's right, folks: we don't just have GO TOs, we have GO TOs whose
* destinations can be changed at will, from anywhere in the program,
* at run time.
GO TO
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
a-paragraph-somewhere.
DISPLAY 'Never heard of him.'
STOP RUN.
some-other-paragraph.
* You think that's bad? You ain't seen nothing.
GO TO
an-arbitrary-paragraph.
DISPLAY 'Edsger who now?'
GO TO some-other-paragraph.
END PROGRAM jumps-program.</syntaxhighlight>
{{out}}
<pre>Edsger who now?
Line 936 ⟶ 949:
'''COBOL''' also supports computed go to phrases, given a list of labels (paragraph names) and an integer index into that list.
<syntaxhighlight lang="
WORKING-STORAGE SECTION.
GO TO quebec, ontario, manitoba DEPENDING ON province</syntaxhighlight>▼
01 province PICTURE IS 99 VALUE IS 2.
PROCEDURE DIVISION.
* Jumps to section or paragraph named 'ontario'.</syntaxhighlight>
=={{header|Common Lisp}}==
Line 3,307 ⟶ 3,325:
The above error messages reveal that TXR Lisp's <code>tagbody</code> is implemented by macros, and relies on a dynamic block return. It is provided mainly for compatibility; Common Lisp users using TXR Lisp may find it handy.
If the <code>tagbody</code> is still active when the lambda tries to perform a <code>go</code>, it works:
<pre>2> (let (fun)
Line 3,458 ⟶ 3,476:
The Fiber class also has a ''try'' method for catching errors (which won't be described here) and a static ''abort'' method which (unless caught) exits the script altogether if an error occurs.
<syntaxhighlight lang="
for (i in 1..10) {
if (i == 1) continue // jumps to next iteration when 'i' equals 1
Line 3,496 ⟶ 3,514:
resuming
aborting
[./
</pre>
Line 3,627 ⟶ 3,645:
{{omit from|Oberon-2}}
{{omit from|UNIX Shell|Does not have goto or line labels, but can break from nested loops}}
{{omit from|Insitux}}
|