99 Bottles of Beer/Basic: Difference between revisions

Content added Content deleted
m (Syntax highlighting fixup)
m (Removed duplicate headers which were causing this task to appear twice in each dialect's task stats. Changed garbled header to 'More concurrent'.)
Line 5: Line 5:
[[99 Bottles of Beer]] done in any of the BASIC-languages.
[[99 Bottles of Beer]] done in any of the BASIC-languages.
__toc__
__toc__
=={{header|BASIC}}==
==BASIC==
==={{header|QBasic}}===
===QBasic===
{{works with|QBasic|1.1}}
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{works with|QuickBasic|4.5}}
Line 27: Line 27:
END</syntaxhighlight>
END</syntaxhighlight>


==={{header|QuickBASIC}}===
===QuickBASIC===
{{works with|QuickBASIC|4.5}}
{{works with|QuickBASIC|4.5}}
====Sound====
====Sound====
Line 53: Line 53:
NEXT x</syntaxhighlight>
NEXT x</syntaxhighlight>


==={{header|Applesoft BASIC}}===
===Applesoft BASIC===
<syntaxhighlight lang="applesoft basic">H$ = "HELLO, WORLD!":B$ = " BOTTLES OF BEER":N$ = CHR$ (13):W$ = " ON THE WALL" + N$: FOR B = 99 TO 1 STEP - 1: PRINT B;B$W$B" "B$N$"TAKE ONE DOWN, PASS IT AROUND"N$B - 1;B$W$: NEXT </syntaxhighlight>
<syntaxhighlight lang="applesoft basic">H$ = "HELLO, WORLD!":B$ = " BOTTLES OF BEER":N$ = CHR$ (13):W$ = " ON THE WALL" + N$: FOR B = 99 TO 1 STEP - 1: PRINT B;B$W$B" "B$N$"TAKE ONE DOWN, PASS IT AROUND"N$B - 1;B$W$: NEXT </syntaxhighlight>


Line 88: Line 88:
NEXT</syntaxhighlight>
NEXT</syntaxhighlight>


==={{header|BASIC256}}===
===BASIC256===
<syntaxhighlight lang="basic256">#length of querter and eight note in ms
<syntaxhighlight lang="basic256">#length of querter and eight note in ms
n4 = 1000 * 60 / 80 / 4
n4 = 1000 * 60 / 80 / 4
Line 125: Line 125:




==={{header|BBC BASIC}}===
===BBC BASIC===
'''Versión más clásica'''
'''Versión más clásica'''
<syntaxhighlight lang="bbcbasic">
<syntaxhighlight lang="bbcbasic">
Line 151: Line 151:
</syntaxhighlight>
</syntaxhighlight>


Alternative version:

==={{header|BBC BASIC}}===


<syntaxhighlight lang="bbcbasic">
<syntaxhighlight lang="bbcbasic">
Line 189: Line 188:
</syntaxhighlight>
</syntaxhighlight>


==={{header|Commodore BASIC}}===
===Commodore BASIC===


You may need to remove the semicolon on line 20 when executing on the VIC-20. Also, this looks best on the machines with 40 or more columns.
You may need to remove the semicolon on line 20 when executing on the VIC-20. Also, this looks best on the machines with 40 or more columns.
Line 214: Line 213:
</syntaxhighlight>
</syntaxhighlight>


==={{header|Creative Basic}}===
===Creative Basic===
====window version====
====window version====
<syntaxhighlight lang="creative basic">DEF Win:WINDOW
<syntaxhighlight lang="creative basic">DEF Win:WINDOW
Line 474: Line 473:
</syntaxhighlight>
</syntaxhighlight>


==={{header|FBSL}}===
===FBSL===
This is a OO version, using FBSL v3.5 Beta
This is a OO version, using FBSL v3.5 Beta
<syntaxhighlight lang="qbasic">#AppType Console
<syntaxhighlight lang="qbasic">#AppType Console
Line 538: Line 537:
</syntaxhighlight>
</syntaxhighlight>


==={{header|FreeBASIC}}===
===FreeBASIC===
==== Normal version ====
==== Normal version ====
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
Line 573: Line 572:
Sleep</syntaxhighlight>
Sleep</syntaxhighlight>


==={{header|FUZE BASIC}}===
===FUZE BASIC===
<syntaxhighlight lang="qbasic">CLS
<syntaxhighlight lang="qbasic">CLS
DIM s$(1)
DIM s$(1)
Line 587: Line 586:
END</syntaxhighlight>
END</syntaxhighlight>


==={{header|Yabasic}}===
===Yabasic===
<syntaxhighlight lang="yabasic">
<syntaxhighlight lang="yabasic">
b$ = " bottles"
b$ = " bottles"
Line 607: Line 606:




==={{header|GW-BASIC}}===
===GW-BASIC===


Just a basic loop counting down to one. No big deal. Note that at BOTTLES=1, it is not
Just a basic loop counting down to one. No big deal. Note that at BOTTLES=1, it is not
Line 620: Line 619:
</syntaxhighlight>
</syntaxhighlight>


==={{header|Integer BASIC}}===
===Integer BASIC===


IMPORTANT NOTE: Integer BASIC was written (and hand-assembled by Woz himself)
IMPORTANT NOTE: Integer BASIC was written (and hand-assembled by Woz himself)
Line 656: Line 655:
RUN</syntaxhighlight>
RUN</syntaxhighlight>


==={{header|Liberty BASIC}}===
===Liberty BASIC===
<syntaxhighlight lang="lb">For bottles = 99 To 1 Step -1
<syntaxhighlight lang="lb">For bottles = 99 To 1 Step -1
song$ = song$ + str$(bottles) + " bottle"
song$ = song$ + str$(bottles) + " bottle"
Line 671: Line 670:
Print song$</syntaxhighlight>
Print song$</syntaxhighlight>


==={{header|Microsoft Small Basic}}===
===Microsoft Small Basic===


<syntaxhighlight lang="microsoftsmallbasic">
<syntaxhighlight lang="microsoftsmallbasic">
Line 693: Line 692:
</syntaxhighlight>
</syntaxhighlight>


==={{header|Minimal BASIC}}===
===Minimal BASIC===
{{trans|BBC BASIC}}
{{trans|BBC BASIC}}
The cases of 99 bottles and of 1 bottle are extracted from the loop. The variable <code>S$</code> is replaced by litterals, <code>T$</code> is divided into two variables (In Minimal BASIC strings assignable to string variables may contain up to 18 chars).
The cases of 99 bottles and of 1 bottle are extracted from the loop. The variable <code>S$</code> is replaced by litterals, <code>T$</code> is divided into two variables (In Minimal BASIC strings assignable to string variables may contain up to 18 chars).
Line 729: Line 728:
</syntaxhighlight>
</syntaxhighlight>


==={{header|MSX Basic}}===
===MSX Basic===


<syntaxhighlight lang="msxbasic">
<syntaxhighlight lang="msxbasic">
Line 741: Line 740:
</syntaxhighlight>
</syntaxhighlight>


==={{header|OxygenBasic}}===
===OxygenBasic===
<syntaxhighlight lang="qbasic">
<syntaxhighlight lang="qbasic">
int x=99
int x=99
Line 773: Line 772:
</syntaxhighlight>
</syntaxhighlight>


==={{header|PowerBASIC}}===
===PowerBASIC===
<syntaxhighlight lang="powerbasic">#COMPILE EXE
<syntaxhighlight lang="powerbasic">#COMPILE EXE
#DIM ALL
#DIM ALL
Line 805: Line 804:
END FUNCTION</syntaxhighlight>
END FUNCTION</syntaxhighlight>


==={{header|PureBasic}}===
===PureBasic===
====Normal version====
====Normal version====
<syntaxhighlight lang="purebasic">If OpenConsole()
<syntaxhighlight lang="purebasic">If OpenConsole()
Line 882: Line 881:
EndIf</syntaxhighlight>
EndIf</syntaxhighlight>


==={{header|QB64}}===
===QB64===
''CBTJD'': 2020/03/08
''CBTJD'': 2020/03/08
* Manages grammatical support for "1 bottle of beer" and "No more bottles of beer".
* Manages grammatical support for "1 bottle of beer" and "No more bottles of beer".
Line 897: Line 896:
NEXT</syntaxhighlight>
NEXT</syntaxhighlight>


==={{header|REALbasic}}===
===REALbasic===
Place the following in the "open" event of a console application.
Place the following in the "open" event of a console application.
<syntaxhighlight lang="vb">dim bottles as Integer = 99
<syntaxhighlight lang="vb">dim bottles as Integer = 99
Line 908: Line 907:
Wend</syntaxhighlight>
Wend</syntaxhighlight>


==={{header|Run BASIC}}===
===Run BASIC===
<syntaxhighlight lang="runbasic">b$ = " bottles"
<syntaxhighlight lang="runbasic">b$ = " bottles"
for bottles = 99 To 1 Step -1
for bottles = 99 To 1 Step -1
Line 922: Line 921:
next bottles</syntaxhighlight>
next bottles</syntaxhighlight>


==={{header|smart BASIC}}===
===smart BASIC===
<syntaxhighlight lang="qbasic">READ b,s$(0),s$(1),a$,b$,c$,d$,e$,f$
<syntaxhighlight lang="qbasic">READ b,s$(0),s$(1),a$,b$,c$,d$,e$,f$
g$ = CHR$(10)
g$ = CHR$(10)
Line 944: Line 943:
END</syntaxhighlight>
END</syntaxhighlight>


==={{header|Sinclair ZX81 BASIC}}===
===Sinclair ZX81 BASIC===
Scrolls after each line so doesn't run out of screen space and stop prematurely!
Scrolls after each line so doesn't run out of screen space and stop prematurely!
<syntaxhighlight lang="basic">10 FOR N=99 TO 1 STEP -1
<syntaxhighlight lang="basic">10 FOR N=99 TO 1 STEP -1
Line 958: Line 957:
110 NEXT N</syntaxhighlight>
110 NEXT N</syntaxhighlight>


==={{header|TI-83 BASIC}}===
===TI-83 BASIC===
<syntaxhighlight lang="ti83b">PROGRAM:BEER
<syntaxhighlight lang="ti83b">PROGRAM:BEER
:For(I,99,1,-1)
:For(I,99,1,-1)
Line 975: Line 974:




==={{header|TI-89 BASIC}}===
===TI-89 BASIC===
<syntaxhighlight lang="ti89b">Prgm
<syntaxhighlight lang="ti89b">Prgm
Local i,plural,clockWas,t,k,wait
Local i,plural,clockWas,t,k,wait
Line 1,024: Line 1,023:
EndPrgm</syntaxhighlight>
EndPrgm</syntaxhighlight>


==={{header|Tiny BASIC}}===
===Tiny BASIC===
<syntaxhighlight lang="tiny basic">100 LET N=99
<syntaxhighlight lang="tiny basic">100 LET N=99
105 GOSUB 120
105 GOSUB 120
Line 1,046: Line 1,045:
</syntaxhighlight>
</syntaxhighlight>


==={{header|True BASIC}}===
===True BASIC===
<syntaxhighlight lang="basic">
<syntaxhighlight lang="basic">
! TrueBASIC v6.007
! TrueBASIC v6.007
Line 1,074: Line 1,073:
</syntaxhighlight>
</syntaxhighlight>


==={{header|Visual Basic}}===
===Visual Basic===
<syntaxhighlight lang="vb">Sub Main()
<syntaxhighlight lang="vb">Sub Main()
Const bottlesofbeer As String = " bottles of beer"
Const bottlesofbeer As String = " bottles of beer"
Line 1,109: Line 1,108:
End Sub</syntaxhighlight>
End Sub</syntaxhighlight>


==={{header|Visual Basic .NET}}===
===Visual Basic .NET===
'''Platform:''' [[.NET]]
'''Platform:''' [[.NET]]


Line 1,581: Line 1,580:
...</pre>
...</pre>


====<s>More</s>D<s> </s>R<s>con</s>U<s>current</s>NK====
====More concurrent====
<syntaxhighlight lang="vbnet">Module Program
<syntaxhighlight lang="vbnet">Module Program
Function Plural(count As Integer) As String
Function Plural(count As Integer) As String
Line 1,667: Line 1,666:
...</pre>
...</pre>


==={{header|XBasic}}===
===XBasic===
{{trans|Microsoft Small Basic}}
{{trans|Microsoft Small Basic}}
{{works with|Windows XBasic}}
{{works with|Windows XBasic}}
Line 1,699: Line 1,698:
</syntaxhighlight>
</syntaxhighlight>


==={{header|ZX Spectrum Basic}}===
===ZX Spectrum Basic===
<syntaxhighlight lang="zxbasic">10 DEF FN n$(b)="no more" AND NOT b
<syntaxhighlight lang="zxbasic">10 DEF FN n$(b)="no more" AND NOT b
20 DEF FN m$(b)=(STR$ b) AND b
20 DEF FN m$(b)=(STR$ b) AND b
Line 1,717: Line 1,716:
160 PRINT "Go to the store and buy some more, 99 bottles of beer on the wall."
160 PRINT "Go to the store and buy some more, 99 bottles of beer on the wall."
</syntaxhighlight>
</syntaxhighlight>
=={{header|VBA}}==
==VBA==
This version uses tail recursion and inline if-statements,
This version uses tail recursion and inline if-statements,
plus a Static variable to count the number of bottles emptied.
plus a Static variable to count the number of bottles emptied.
Line 1,770: Line 1,769:


</pre>
</pre>
=={{header|VBScript}}==
==VBScript==
===Simple Method===
===Simple Method===
<syntaxhighlight lang="vb">sub song( numBottles )
<syntaxhighlight lang="vb">sub song( numBottles )