99 Bottles of Beer/Basic: Difference between revisions

no edit summary
(99 Bottles of Beer/Basic in Chipmunk Basic)
No edit summary
 
(4 intermediate revisions by 2 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>
 
===Chipmunk Basic{{header|bootBASIC}}===
In bootBASIC lines are limited to 19 characters.
<syntaxhighlight lang="msxbasicBASIC">
int5 xa=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"
1030 FOR X 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}}
Line 160 ⟶ 218:
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 182 ⟶ 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
 
Line 214 ⟶ 269:
end</syntaxhighlight>
 
==={{header|Creative Basic}}===
====window version====
<syntaxhighlight lang="creative basic">DEF Win:WINDOW
Line 357 ⟶ 412:
NEXT X
 
RETURN</syntaxhighlight>
</syntaxhighlight>
====console only version====
Rather quickly written and dirty.
Line 471 ⟶ 525:
END
 
RETURN</syntaxhighlight>
</syntaxhighlight>
 
==={{header|FBSL}}===
This is a OO version, using FBSL v3.5 Beta
<syntaxhighlight lang="qbasic">#AppType Console
Line 538 ⟶ 591:
</syntaxhighlight>
 
==={{header|FreeBASIC}}===
==== Normal version ====
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
Line 573 ⟶ 626:
Sleep</syntaxhighlight>
 
==={{header|FUZE BASIC}}===
<syntaxhighlight lang="qbasic">CLS
DIM s$(1)
Line 587 ⟶ 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 600 ⟶ 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 636 ⟶ 687:
RUN</syntaxhighlight>
 
==={{header|Liberty BASIC}}===
<syntaxhighlight lang="lb">For bottles = 99 To 1 Step -1
song$ = song$ + str$(bottles) + " bottle"
Line 651 ⟶ 702:
Print song$</syntaxhighlight>
 
==={{header|Microsoft Small Basic}}===
 
<syntaxhighlight lang="microsoftsmallbasic">
For n = 99 To 1 Step -1
Line 673 ⟶ 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 706 ⟶ 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 718 ⟶ 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 750 ⟶ 795:
next
'
putfile "t.txt",pr </syntaxhighlight>
</syntaxhighlight>
 
==={{header|PowerBASIC}}===
<syntaxhighlight lang="powerbasic">#COMPILE EXE
#DIM ALL
Line 785 ⟶ 829:
END FUNCTION</syntaxhighlight>
 
==={{header|PureBasic}}===
====Normal version====
<syntaxhighlight lang="purebasic">If OpenConsole()
Line 862 ⟶ 906:
EndIf</syntaxhighlight>
 
==={{header|QB64}}===
''CBTJD'': 2020/03/08
* Manages grammatical support for "1 bottle of beer" and "No more bottles of beer".
Line 877 ⟶ 921:
NEXT</syntaxhighlight>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
Line 898 ⟶ 942:
END</syntaxhighlight>
 
==={{header|QuickBASIC}}===
{{works with|QuickBASIC|4.5}}
====Sound====
Line 924 ⟶ 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 935 ⟶ 979:
Wend</syntaxhighlight>
 
==={{header|Run BASIC}}===
<syntaxhighlight lang="runbasic">b$ = " bottles"
for bottles = 99 To 1 Step -1
Line 949 ⟶ 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 963 ⟶ 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 985 ⟶ 1,029:
END</syntaxhighlight>
 
==={{header|TI-83 BASIC}}===
<syntaxhighlight lang="ti83b">PROGRAM:BEER
:For(I,99,1,-1)
Line 998 ⟶ 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,050 ⟶ 1,093:
EndPrgm</syntaxhighlight>
 
===Tiny BASIC{{header|Tiny_Basic}}===
{{works with|TinyBasic}}
<syntaxhighlight lang="basic">100 LET N=99
Line 1,070 ⟶ 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,098 ⟶ 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,136 ⟶ 1,176:
End Sub</syntaxhighlight>
 
==={{header|Visual Basic .NET}}===
'''Platform:''' [[.NET]]
 
Line 1,694 ⟶ 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,723 ⟶ 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,742 ⟶ 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,761 ⟶ 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,813 ⟶ 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 )