Jump anywhere: Difference between revisions
PascalABC.NET
(Added Chipmunk Basic, GW-BASIC, True BASIC, Quite BASIC, Minimal BASIC and MSX Basic.) |
(PascalABC.NET) |
||
(5 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.
=={{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 start-paragraph TO PROCEED TO a-paragraph-somewhere.
* 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.
01 province PICTURE IS 99 VALUE IS 2.
PROCEDURE DIVISION.
GO TO quebec, ontario, manitoba DEPENDING ON province.
* Jumps to section or paragraph named 'ontario'.</syntaxhighlight>
=={{header|Common Lisp}}==
Line 2,412 ⟶ 2,430:
PARI inherits C's ability to <code>goto</code> or <code>longjmp</code>; the latter is used extensively in the library.
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
label finish;
begin
var a := MatrRandomInteger(3,4);
var found := False;
for var i:=0 to a.RowCount-1 do
for var j:=0 to a.ColCount-1 do
if a[i,j] = 10 then
begin
found := True;
goto finish;
end;
finish:
Print(found);
end.
</syntaxhighlight>
=={{header|Perl}}==
Line 3,307 ⟶ 3,344:
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,495:
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,533:
resuming
aborting
[./
</pre>
Line 3,627 ⟶ 3,664:
{{omit from|Oberon-2}}
{{omit from|UNIX Shell|Does not have goto or line labels, but can break from nested loops}}
{{omit from|Insitux}}
|