Loops/For with a specified step: Difference between revisions

Added Chipmunk Basic, GW-BASIC, Minimal BASIC, MSX Basic QBasic, Quite BASIC and Tiny BASIC
(Loops/For with a specified step in Dart)
(Added Chipmunk Basic, GW-BASIC, Minimal BASIC, MSX Basic QBasic, Quite BASIC and Tiny BASIC)
Line 602:
8
</pre>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">10 for i = 1 to 21 step 2
20 print i;
30 next i</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
Line 633 ⟶ 639:
for i = 0 to 10 step 2
print s(i);
next</syntaxhighlight>
next
{{out}}
</syntaxhighlight>
<pre>Somewhere over the rainbow
Output:
Bluebirds fly.</pre>
Somewhere over the rainbow
Bluebirds fly.
</pre>
 
==={{header|Gambas}}===
Line 651 ⟶ 654:
 
End</syntaxhighlight>
<pre>Gambas is great!
Gambas is great!
Gambas is great!
Line 660 ⟶ 663:
Gambas is great!
Gambas is great!
Gambas is great!</pre>
 
Gambas is great!
==={{header|GW-BASIC}}===
</pre>
{{works with|BASICA}}
{{works with|PC-BASIC|any}}
<syntaxhighlight lang="qbasic">10 FOR I = 1 TO 21 STEP 2
20 PRINT I;
30 NEXT I</syntaxhighlight>
 
==={{header|IS-BASIC}}===
Line 670 ⟶ 678:
 
==={{header|Liberty BASIC}}===
<syntaxhighlight lang="lb">for i = 2 to 8 step 2
for i = 2 to 8 step 2
print i; ", ";
next i
print "who do we appreciate?"
end</syntaxhighlight>
end
</syntaxhighlight>
 
==={{header|Microsoft Small Basic}}===
<syntaxhighlight lang="microsoftsmallbasic">For i = 0 To 100 Step 2
For i = 0 To 100 Step 2
TextWindow.WriteLine(i)
EndFor</syntaxhighlight>
 
</syntaxhighlight>
==={{header|Minimal BASIC}}===
{{works with|QBasic}}
{{works with|QuickBasic}}
{{works with|Applesoft BASIC}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
{{works with|Run BASIC}}
{{works with|Yabasic}}
<syntaxhighlight lang="qbasic">10 FOR I = 1 TO 21 STEP 2
20 PRINT I; " ";
30 NEXT I
40 END</syntaxhighlight>
 
==={{header|MSX Basic}}===
<syntaxhighlight lang="qbasic">10 FOR I = 1 TO 21 STEP 2
20 PRINT I;
30 NEXT I</syntaxhighlight>
 
==={{header|NS-HUBASIC}}===
Line 689 ⟶ 715:
20 PRINT I
30 NEXT</syntaxhighlight>
 
{{out}}
<pre> 1 3 5 7 9 11 13 15 17 19 21</pre>
<pre>
1 3 5 7 9 11 13 15 17 19 21
</pre>
 
==={{header|PureBasic}}===
Line 700 ⟶ 723:
Next i</syntaxhighlight>
{{out}}
<pre>-15
-15
-10
-5
Line 709 ⟶ 731:
15
20
25</pre>
</pre>
 
Decrementing with step
Line 717 ⟶ 738:
Next ; i is optional</syntaxhighlight>
{{out}}
<pre>10
10
8
6
4
2
0</pre>
0
</pre>
 
==={{header|QB64}}===
Line 733 ⟶ 752:
{{out}}
A newline is inserted automatically after the Print statement
<pre>0
0
2
4
6
8
10</pre>
</pre>
 
We can also decrement with stepping
<syntaxhighlight lang="qbasic">For i% = 10 to 0 Step -2
Print i%
Next i </syntaxhighlight>
</syntaxhighlight>
{{out}}
<pre>10
 
<pre>
10
8
6
4
2
9</pre>
9
 
</pre>
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">FOR i = 1 TO 21 STEP 2
PRINT i;
NEXT i</syntaxhighlight>
 
==={{header|Quite BASIC}}===
<syntaxhighlight lang="qbasic">10 FOR I = 1 TO 21 STEP 2
20 PRINT I; " ";
30 NEXT I</syntaxhighlight>
 
==={{header|Run BASIC}}===
Line 786 ⟶ 811:
Disp i
EndFor</syntaxhighlight>
 
==={{Header|Tiny BASIC}}===
<syntaxhighlight lang="qbasic"> REM TinyBasic does not have a for-loop construct.
REM Equivalent using conditional jump:
 
LET i = 1
10 IF i > 21 THEN GOTO 20
PRINT i
LET i = i + 2
GOTO 10
20 END</syntaxhighlight>
 
==={{header|True BASIC}}===
Line 795 ⟶ 831:
</syntaxhighlight>
{{out}}
<pre>1 3 5 7 9 11 13 15 17 19 21</pre>
<pre>
1 3 5 7 9 11 13 15 17 19 21
</pre>
Since TrueBasic does not distinguish between integer or real values, we can increment using decimal values as well
 
<syntaxhighlight lang="qbasic">FOR i = 1 TO 5 STEP .5
FOR i = 1 TO 5 STEP .5
PRINT i
NEXT i
END</syntaxhighlight>
END
</syntaxhighlight>
{{out}}
<pre>1
1
1.5
2
Line 816 ⟶ 847:
4
4.5
5</pre>
5
</pre>
 
==={{header|Visual Basic}}===
Line 828 ⟶ 858:
End Sub</syntaxhighlight>
{{out}}
<pre> 2 4 6 8 </pre>
2 4 6 8
</pre>
 
==={{header|Visual Basic .NET}}===
Line 844 ⟶ 872:
End Module</syntaxhighlight>
{{out}}
<pre>2, 4, 6, 8, who do we appreciate?</pre>
<pre>
2, 4, 6, 8, who do we appreciate?
</pre>
 
{{works with|Visual Basic .NET|2011}}
Line 860 ⟶ 886:
End Class</syntaxhighlight>
{{out}}
<pre>2 4 6 8 </pre>
2 4 6 8
</pre>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="xbasic">PROGRAM "forby"
PROGRAM "forby"
 
DECLARE FUNCTION Entry()
Line 876 ⟶ 899:
NEXT i%
END FUNCTION
END PROGRAM</syntaxhighlight>
</syntaxhighlight>
 
==={{header|Yabasic}}===
2,130

edits