99 Bottles of Beer/Basic: Difference between revisions

no edit summary
m (→‎{{header|Tiny BASIC}}: Works with (Tom Pittman's) TinyBasic.)
No edit summary
 
(7 intermediate revisions by 3 users not shown)
Line 5:
[[99 Bottles of Beer]] done in any of the BASIC-languages.
__toc__
=={{header|BASIC}}==
 
==={{header|Applesoft BASIC}}===
<syntaxhighlight lang="applesoft basicqbasic">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>
 
==={{header|BaCon}}===
With lyrics and punctuation taken from the 99-bottles-of-beer.net site.
<syntaxhighlight lang="freebasic">' 99 bottles of beer on the wall
Line 42:
NEXT</syntaxhighlight>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">#length of querter and eight note in ms
n4 = 1000 * 60 / 80 / 4
Line 78:
</syntaxhighlight>
 
==={{header|BBC BASIC}}===
'''Versión más clásica'''
<syntaxhighlight lang="bbcbasic">REM 99 bottles of beer song BBC BASIC version
REM 99 bottles of beer song BBC BASIC version
REM original code by Stelio Passaris (stelio.net)
:
Line 101 ⟶ 100:
PRINT"Go to the store and buy some more,"
PRINT"99 bottles of beer on the wall."
VDU15:REM deshabilita el modo de paginación</syntaxhighlight>
</syntaxhighlight>
 
Alternative version:
Line 141 ⟶ 139:
</syntaxhighlight>
 
===Commodore BASIC{{header|bootBASIC}}===
In bootBASIC lines are limited to 19 characters.
<syntaxhighlight lang="BASIC">
5 a=99
10 print a ;
20 print " bottle";
22 if a-1 print "s";
24 print " ";
30 print "of beer ";
40 print "on the ";
50 print "wall!"
60 print a ;
70 print " bottle";
72 if a-1 print "s";
74 print " ";
80 print "of beer!"
90 print "Take one ";
100 print "down, pass";
110 print " it around!"
115 a=a-1
120 print a ;
130 print " bottle";
132 if a-1 print "s";
134 print " ";
140 print "of beer ";
150 print "on the ";
160 print "wall!"
170 print
180 if a goto 10
</syntaxhighlight>
 
==={{header|Commander X16 BASIC}}===
<syntaxhighlight lang="BASIC">
10 PSGINIT
20 PSGPLAY 0, "T220L4"
30 FOR Z=99 TO 1 STEP -1
40 PRINT Z; "BOTTLE";
50 IF Z <> 1 THEN PRINT "S";
60 PRINT " ";
70 PRINT "OF BEER ON THE WALL!"
80 PSGPLAY 0,"GGGDDDGGGG2."
90 PRINT Z; "BOTTLE";
100 IF Z <> 1 THEN PRINT "S";
110 PRINT " ";
120 PRINT "OF BEER!"
130 PSGPLAY 0,"AAAEEES0A2.A2.S1"
140 PRINT " TAKE ONE DOWN"
150 PSGPLAY 0,"F+2F+F+2."
160 PRINT " PASS IT AROUND"
170 PSGPLAY 0,"F+F+F+F+2."
180 PRINT Z-1; "BOTTLE";
190 IF Z <> 2 THEN PRINT "S";
200 PRINT " ";
210 PRINT "OF BEER ON THE WALL!"
220 PSGPLAY 0,"DDDDEF+GGGG2."
230 PRINT
240 NEXT Z
</syntaxhighlight>
 
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
{{works with|GW-BASIC}}
<syntaxhighlight lang="qbasic">10 cls
20 s$ = "s"
30 for bottles = 99 to 1 step -1
40 print bottles "bottle" s$ " of beer on the wall, "
50 print bottles "bottle" s$ " of beer."
60 print "Take one down and pass it around, "
70 if bottles = 2 then s$ = ""
80 if bottles > 1 then print (bottles-1)"bottle" s$ " of beer on the wall..." else print "no more bottles of beer on the wall..."
90 print
100 next bottles
110 print "No more bottles of beer on the wall,"
120 print "no more bottles of beer."
130 print "Go to the store and buy some more,"
140 print "99 bottles of beer on the wall."
150 end</syntaxhighlight>
 
==={{header|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.
 
<syntaxhighlight lang="freebasic">10 dim bo$(2):bo$(0)="bottle":bo$(1)="bottles"
10 dim bo$(2):bo$(0)="bottle":bo$(1)="bottles"
15 print chr$(147);chr$(14);"99 Bottles of Beer Song"
20 print:print "Start with how many bottles";
Line 163 ⟶ 238:
130 if k$="q" then end
135 rem move to next verse
140 print:next c</syntaxhighlight>
 
</syntaxhighlight>
==={{header|Craft Basic}}===
<syntaxhighlight lang="basic">'99 bottles of beer on the wall
 
for beer = 99 to 1 step - 1
 
if beer > 1 then
 
print beer, " bottles of beer on the wall."
print beer, " bottles of beer!"
 
endif
 
if beer = 1 then
 
print beer, " bottle of beer on the wall."
print "1 more bottle of beer!"
 
endif
 
print "take one down and pass it around..."
 
wait
 
next beer
 
alert "All out of beer!"
 
end</syntaxhighlight>
 
==={{header|Creative Basic}}===
====window version====
<syntaxhighlight lang="creative basic">DEF Win:WINDOW
Line 309 ⟶ 412:
NEXT X
 
RETURN</syntaxhighlight>
</syntaxhighlight>
====console only version====
Rather quickly written and dirty.
Line 423 ⟶ 525:
END
 
RETURN</syntaxhighlight>
</syntaxhighlight>
 
==={{header|FBSL}}===
This is a OO version, using FBSL v3.5 Beta
<syntaxhighlight lang="qbasic">#AppType Console
Line 490 ⟶ 591:
</syntaxhighlight>
 
==={{header|FreeBASIC}}===
==== Normal version ====
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
Line 525 ⟶ 626:
Sleep</syntaxhighlight>
 
==={{header|FUZE BASIC}}===
<syntaxhighlight lang="qbasic">CLS
DIM s$(1)
Line 539 ⟶ 640:
END</syntaxhighlight>
 
==={{header|GW-BASIC}}===
 
Just a basic loop counting down to one. No big deal. Note that at BOTTLES=1, it is not
grammatically correct.
Line 552 ⟶ 652:
</syntaxhighlight>
 
==={{header|Integer BASIC}}===
 
IMPORTANT NOTE: Integer BASIC was written (and hand-assembled by Woz himself)
for the Apple 1 and original Apple 2.
Line 588 ⟶ 687:
RUN</syntaxhighlight>
 
==={{header|Liberty BASIC}}===
<syntaxhighlight lang="lb">For bottles = 99 To 1 Step -1
song$ = song$ + str$(bottles) + " bottle"
Line 603 ⟶ 702:
Print song$</syntaxhighlight>
 
==={{header|Microsoft Small Basic}}===
 
<syntaxhighlight lang="microsoftsmallbasic">
For n = 99 To 1 Step -1
Line 625 ⟶ 723:
</syntaxhighlight>
 
==={{header|Minimal 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).
Line 658 ⟶ 756:
280 PRINT "Go to the store and buy some more,"
290 PRINT "99 bottles of beer on the wall."
300 END</syntaxhighlight>
</syntaxhighlight>
 
==={{header|MSX Basic}}===
<syntaxhighlight lang="qbasic">10 FOR X = 99 TO 1 STEP -1
 
<syntaxhighlight lang="msxbasic">
10 FOR X = 99 TO 1 STEP -1
20 PRINT X; "bottles of beer on the wall"
30 PRINT X; "bottles of beer"
Line 670 ⟶ 765:
50 PRINT X-1; "bottles of beer on the wall"
60 PRINT
70 NEXT X</syntaxhighlight>
</syntaxhighlight>
 
==={{header|OxygenBasic}}===
<syntaxhighlight lang="qbasic">int x=99
int x=99
string cr,tab,pr,bottles,bottlem,remain
cr=chr(13) chr(10)
Line 702 ⟶ 795:
next
'
putfile "t.txt",pr </syntaxhighlight>
</syntaxhighlight>
 
==={{header|PowerBASIC}}===
<syntaxhighlight lang="powerbasic">#COMPILE EXE
#DIM ALL
Line 737 ⟶ 829:
END FUNCTION</syntaxhighlight>
 
==={{header|PureBasic}}===
====Normal version====
<syntaxhighlight lang="purebasic">If OpenConsole()
Line 814 ⟶ 906:
EndIf</syntaxhighlight>
 
==={{header|QB64}}===
''CBTJD'': 2020/03/08
* Manages grammatical support for "1 bottle of beer" and "No more bottles of beer".
Line 829 ⟶ 921:
NEXT</syntaxhighlight>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
Line 850 ⟶ 942:
END</syntaxhighlight>
 
==={{header|QuickBASIC}}===
{{works with|QuickBASIC|4.5}}
====Sound====
Line 876 ⟶ 968:
NEXT x</syntaxhighlight>
 
==={{header|REALbasic}}===
Place the following in the "open" event of a console application.
<syntaxhighlight lang="vb">dim bottles as Integer = 99
Line 887 ⟶ 979:
Wend</syntaxhighlight>
 
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">b$ = " bottles"
for bottles = 99 To 1 Step -1
Line 901 ⟶ 993:
next bottles</syntaxhighlight>
 
==={{header|Sinclair ZX81 BASIC}}===
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
Line 915 ⟶ 1,007:
110 NEXT N</syntaxhighlight>
 
==={{header|smart BASIC}}===
<syntaxhighlight lang="qbasic">READ b,s$(0),s$(1),a$,b$,c$,d$,e$,f$
g$ = CHR$(10)
Line 937 ⟶ 1,029:
END</syntaxhighlight>
 
==={{header|TI-83 BASIC}}===
<syntaxhighlight lang="ti83b">PROGRAM:BEER
:For(I,99,1,-1)
Line 950 ⟶ 1,042:
:Disp "BOTTLES OF BEER"
:Disp "ON THE WALL."
:End</syntaxhighlight>
:End
</syntaxhighlight>
 
==={{header|TI-89 BASIC}}===
<syntaxhighlight lang="ti89b">Prgm
Local i,plural,clockWas,t,k,wait
Line 1,002 ⟶ 1,093:
EndPrgm</syntaxhighlight>
 
===Tiny BASIC{{header|Tiny_Basic}}===
{{works with|TinyBasic}}
<syntaxhighlight lang="basic">100 LET N=99
Line 1,022 ⟶ 1,113:
180 IF N=1 THEN PRINT N," bottle of beer"
185 IF N>1 THEN PRINT N," bottles of beer"
190 RETURN</syntaxhighlight>
</syntaxhighlight>
 
===True BASIC{{header|True_BASIC}}===
<syntaxhighlight lang="basic">! TrueBASIC v6.007
! TrueBASIC v6.007
 
LET bottles = 99
Line 1,050 ⟶ 1,139:
PRINT "Press any key to sleep it off"
GET KEY done
END</syntaxhighlight>
END
</syntaxhighlight>
 
==={{header|Visual Basic}}===
<syntaxhighlight lang="vb">Sub Main()
Const bottlesofbeer As String = " bottles of beer"
Line 1,088 ⟶ 1,176:
End Sub</syntaxhighlight>
 
==={{header|Visual Basic .NET}}===
'''Platform:''' [[.NET]]
 
Line 1,646 ⟶ 1,734:
...</pre>
 
==={{header|XBasic}}===
{{trans|Microsoft Small Basic}}
{{works with|Windows XBasic}}
<syntaxhighlight lang="xbasic">PROGRAM "99bottles"
PROGRAM "99bottles"
VERSION "0.0001"
 
Line 1,675 ⟶ 1,762:
NEXT n@@
END FUNCTION
END PROGRAM</syntaxhighlight>
</syntaxhighlight>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">b$ = " bottles"
b$ = " bottles"
for bottles = 99 to 1 step -1
if (bottles = 1) then b$ = " bottle" : fi
Line 1,694 ⟶ 1,779:
end if
next bottles
end</syntaxhighlight>
end
</syntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
<syntaxhighlight lang="zxbasic">10 DEF FN n$(b)="no more" AND NOT b
20 DEF FN m$(b)=(STR$ b) AND b
Line 1,713 ⟶ 1,797:
140 PRINT
150 NEXT i
160 PRINT "Go to the store and buy some more, 99 bottles of beer on the wall."</syntaxhighlight>
 
</syntaxhighlight>
=={{header|VBA}}==
This version uses tail recursion and inline if-statements,
plus a Static variable to count the number of bottles emptied.
Line 1,765 ⟶ 1,849:
no more bottles of Johnnie Walker
go to the store and buy some more
3 bottles of Johnnie Walker on the wall</pre>
 
=={{header|VBScript}}==
</pre>
==VBScript==
===Simple Method===
<syntaxhighlight lang="vb">sub song( numBottles )