Jump anywhere: Difference between revisions

PascalABC.NET
(Added Tiny BASIC)
(PascalABC.NET)
(4 intermediate revisions by 3 users not shown)
Line 911:
 
=={{header|COBOL}}==
<syntaxhighlight lang="cobolcobolfree"> IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPSjumps-PROGRAMprogram.
* Nobody writes like this, of course; but...
 
PROCEDURE DIVISION.
 
* You can jump anywhere you like.
start-paragraph.
START-PARAGRAPH.
GO TO ANan-ARBITRARYarbitrary-PARAGRAPHparagraph.
 
YET-ANOTHER-PARAGRAPH.
yet-another-paragraph.
ALTER STARTstart-PARAGRAPHparagraph TO PROCEED TO Aa-PARAGRAPHparagraph-SOMEWHEREsomewhere.
* 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 STARTstart-PARAGRAPHparagraph.
* But bear in mind: once you get there, the GO TO no longer goes to
* where it says it goes to.
 
A-PARAGRAPH-SOMEWHERE.
a-paragraph-somewhere.
DISPLAY 'Never heard of him.'
STOP RUN.
SOME-OTHER-PARAGRAPH.
 
some-other-paragraph.
* You think that's bad? You ain't seen nothing.
GO TO YETyet-ANOTHERanother-PARAGRAPHparagraph.
 
AN-ARBITRARY-PARAGRAPH.
an-arbitrary-paragraph.
DISPLAY 'Edsger who now?'
GO TO SOME-OTHER-PARAGRAPH.</syntaxhighlight>
GO TO some-other-paragraph.
 
END PROGRAM jumps-program.</syntaxhighlight>
{{out}}
<pre>Edsger who now?
Line 941 ⟶ 949:
'''COBOL''' also supports computed go to phrases, given a list of labels (paragraph names) and an integer index into that list.
 
<syntaxhighlight lang="cobolcobolfree">01 provinceDATA pic 99 value 2DIVISION.
WORKING-STORAGE SECTION.
GO TO quebec, ontario, manitoba DEPENDING ON province</syntaxhighlight>
01 province PICTURE IS 99 VALUE IS 2.
 
PROCEDURE DIVISION.
GO TO quebec, ontario, manitoba DEPENDING ON province</syntaxhighlight>.
* Jumps to section or paragraph named 'ontario'.</syntaxhighlight>
 
=={{header|Common Lisp}}==
Line 2,417 ⟶ 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,312 ⟶ 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,463 ⟶ 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="ecmascriptwren">var func = Fn.new {
for (i in 1..10) {
if (i == 1) continue // jumps to next iteration when 'i' equals 1
Line 3,501 ⟶ 3,533:
resuming
aborting
[./jumpJump_anywhere line 17] in new(_) block argument
</pre>
 
Line 3,632 ⟶ 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}}
242

edits