Repeat: Difference between revisions
Content added Content deleted
(Added various dialects BASIC (BASIC256, QBasic, Chipmunk Basic, GW-BASIC, True BASIC, Minimal BASIC, MSX Basic, Quite BASIC and XBasic)) |
|||
Line 423: | Line 423: | ||
inside odd 3 |
inside odd 3 |
||
</pre> |
</pre> |
||
=={{header|BASIC}}== |
|||
==={{header|BASIC256}}=== |
|||
<syntaxhighlight lang="vb">subroutine proc() |
|||
print " Inside loop" |
|||
end subroutine |
|||
subroutine repeat(func, times) |
|||
for i = 1 to times |
|||
call proc() |
|||
next |
|||
end subroutine |
|||
call repeat("proc", 5) |
|||
print "Loop Ended</syntaxhighlight> |
|||
{{out}} |
|||
<pre> Inside loop |
|||
Inside loop |
|||
Inside loop |
|||
Inside loop |
|||
Inside loop |
|||
Loop Ended</pre> |
|||
==={{header|Chipmunk Basic}}=== |
|||
{{works with|Chipmunk Basic|3.6.4}} |
|||
<syntaxhighlight lang="qbasic">10 sub proc() |
|||
20 print " Inside loop" |
|||
30 end sub |
|||
40 sub repeat(func$,times) |
|||
50 for i = 1 to times |
|||
60 proc() |
|||
70 next i |
|||
80 end sub |
|||
90 repeat("proc",5) |
|||
100 print "Loop Ended" |
|||
110 end</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as BASIC256 entry.</pre> |
|||
==={{header|GW-BASIC}}=== |
|||
{{works with|BASICA}} |
|||
{{works with|Chipmunk Basic}} |
|||
{{works with|Just 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 let f$ = "proc" |
|||
110 let c = 5 |
|||
120 gosub 170 |
|||
130 print "Loop Ended" |
|||
140 goto 220 |
|||
150 print " Inside loop" |
|||
160 return |
|||
170 rem repeat(f$,c) |
|||
180 for i = 1 to c |
|||
190 gosub 150 |
|||
200 next i |
|||
210 return |
|||
220 end</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as BASIC256 entry.</pre> |
|||
==={{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|QBasic}}=== |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBasic|4.5}} |
|||
<syntaxhighlight lang="qbasic">DECLARE SUB rep (func AS STRING, c AS INTEGER) |
|||
DECLARE SUB proc () |
|||
CALL rep("proc", 5) |
|||
PRINT "Loop Ended" |
|||
SUB proc |
|||
PRINT " Inside loop" |
|||
END SUB |
|||
SUB rep (func AS STRING, c AS INTEGER) |
|||
FOR i = 1 TO c |
|||
proc |
|||
NEXT |
|||
END SUB</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as BASIC256 entry.</pre> |
|||
==={{header|Quite BASIC}}=== |
|||
The [[#GW-BASIC|GW-BASIC]] solution works without any changes. |
|||
==={{header|True BASIC}}=== |
|||
<syntaxhighlight lang="qbasic">SUB proc |
|||
PRINT " Inside loop" |
|||
END SUB |
|||
SUB rep (func$, c) |
|||
FOR i = 1 to c |
|||
CALL proc |
|||
NEXT i |
|||
END SUB |
|||
CALL rep ("proc", 5) |
|||
PRINT "Loop Ended" |
|||
END</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as BASIC256 entry.</pre> |
|||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
<syntaxhighlight lang="qbasic">PROGRAM "Repeat" |
|||
VERSION "0.0000" |
|||
DECLARE FUNCTION Entry () |
|||
DECLARE FUNCTION Proc () |
|||
DECLARE FUNCTION Repe (func$, c) |
|||
FUNCTION Entry () |
|||
Repe ("proc", 5) |
|||
PRINT "Loop Ended" |
|||
END FUNCTION |
|||
FUNCTION Proc () |
|||
PRINT " Inside loop" |
|||
END FUNCTION |
|||
FUNCTION Repe (func$, c) |
|||
FOR i = 1 TO c |
|||
Proc () |
|||
NEXT i |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as BASIC256 entry.</pre> |
|||
=={{header|Batch File}}== |
=={{header|Batch File}}== |