Jump anywhere: Difference between revisions

m
→‎{{header|TXR}}: Fixed unfinished </code> tag
(add task to aarch64 assembly raspberry pi)
m (→‎{{header|TXR}}: Fixed unfinished </code> tag)
(5 intermediate revisions by 4 users not shown)
Line 534:
<syntaxhighlight lang="applesoftbasic">CONT : REM CONTINUE, JUMP BACK TO WHERE THE PROGRAM STOPPED</syntaxhighlight>
 
==={{header|IS-BASICBASIC256}}===
<syntaxhighlight lang="is-basic">10 GOTO 100 ! jump to a specific line
20 RUN 200 ! start the program running from a specific line</syntaxhighlight>
 
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">for i = 1 to 10
if i = 5 then goto [label5]
next i
end
 
[label5]
print i
while i < 10
if i = 6 then goto [label6]
i = i + 1
wend
end
 
[label6]
print i
if i = 6 then goto [finish]
print "Why am I here"
 
[finish]
print "done"</syntaxhighlight>
 
=={{header|BASIC256}}==
BASIC256 supports both <code>goto</code> and <code>gosub</code>.
{{works with|QBasic}}
Line 588 ⟶ 562:
{{out}}
<pre>Igual que la entrada de FutureBasic.</pre>
 
==={{header|Chipmunk Basic}}===
Chipmunk Basic supports both <code>goto</code> and <code>gosub</code>.
{{works with|Chipmunk Basic|3.6.4}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">100 CLS
110 PRINT "First line."
120 GOSUB sub1
130 PRINT "Fifth line."
140 GOTO Ending
150 sub1:
160 PRINT "Second line."
170 GOSUB sub2
180 PRINT "Fourth line."
190 RETURN
200 Ending:
210 PRINT "We're just about done..."
220 GOTO Finished
230 sub2:
240 PRINT "Third line."
250 RETURN
260 Finished:
270 PRINT "... with goto and gosub, thankfully."
280 END</syntaxhighlight>
{{out}}
<pre>Same as FutureBasic entry.</pre>
 
==={{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}}
{{works with|Minimal BASIC}}
{{works with|MSX BASIC|any}}
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
{{works with|Quite BASIC}}
<syntaxhighlight lang="qbasic">100 PRINT "First line."
110 GOSUB 140
120 PRINT "Fifth line."
130 GOTO 190
140 REM sub1:
150 PRINT "Second line."
160 GOSUB 220
170 PRINT "Fourth line."
180 RETURN
190 REM Ending:
200 PRINT "We're just about done..."
210 GOTO 250
220 REM sub2:
230 PRINT "Third line."
240 RETURN
250 REM Finished:
260 PRINT "... with goto and gosub, thankfully."
270 END</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">10 GOTO 100 ! jump to a specific line
20 RUN 200 ! start the program running from a specific line</syntaxhighlight>
 
==={{header|Minimal BASIC}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|MSX Basic}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|Quite BASIC}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">for i = 1 to 10
if i = 5 then goto [label5]
next i
end
 
[label5]
print i
while i < 10
if i = 6 then goto [label6]
i = i + 1
wend
end
 
[label6]
print i
if i = 6 then goto [finish]
print "Why am I here"
 
[finish]
print "done"</syntaxhighlight>
 
==={{header|True BASIC}}===
True BASIC supports both <code>goto</code> and <code>gosub</code>.
<syntaxhighlight lang="qbasic">100 ! Jump anywhere
110 CLEAR
120 PRINT "First line."
130 GOSUB 160
140 PRINT "Fifth line."
150 GOTO 210
160 ! sub1:
170 PRINT "Second line."
180 GOSUB 250
190 PRINT "Fourth line."
200 RETURN
210 ! Ending:
220 PRINT "We're just about done..."
230 GOTO 270
240 ! sub2:
250 PRINT "Third line."
260 RETURN
270 ! Finished:
280 PRINT "... with goto and gosub, thankfully."
290 END</syntaxhighlight>
{{out}}
<pre>Same as FutureBasic entry.</pre>
 
==={{Header|Tiny BASIC}}===
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
=={{header|BQN}}==
Line 819 ⟶ 911:
 
=={{header|COBOL}}==
<syntaxhighlight lang="cobolcobolfree"> IDENTIFICATION DIVISION.
PROGRAM-ID. JUMPSjumps-PROGRAMprogram.
* Nobody writes like this, of course; but...
 
PROCEDURE DIVISION.
PROCEDURE DIVISION.
 
* You can jump anywhere you like.
start-paragraph.
START-PARAGRAPH.
GO TO ANan-ARBITRARYarbitrary-PARAGRAPHparagraph.
 
YET-ANOTHER-PARAGRAPH.
yet-another-paragraph.
ALTER START-PARAGRAPH TO PROCEED TO A-PARAGRAPH-SOMEWHERE.
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 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.'
DISPLAY 'Never heard of him.'
STOP RUN.
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?'
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 849 ⟶ 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.
* Jumps to section or paragraph named 'ontario'.</syntaxhighlight>
 
=={{header|Common Lisp}}==
Line 3,220 ⟶ 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,371 ⟶ 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="ecmascriptwren">var func = Fn.new {
for (i in 1..10) {
if (i == 1) continue // jumps to next iteration when 'i' equals 1
Line 3,409 ⟶ 3,514:
resuming
aborting
[./jumpJump_anywhere line 17] in new(_) block argument
</pre>
 
Line 3,540 ⟶ 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}}
9,487

edits