99 Bottles of Beer
One program in 571 languages
 
     
  Submit new example     Change log     History     Links     Tip: internet.ls-la.net     Thanks, Oliver     Guestbook      
Choose languages starting with letter:
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
WebDNA   WebL   Whenever   Whitespace   WIL   WinAPI with C++   WinBatch   Wise InstallMaster8   Word   WordBasic   WoS Quest Script   wxBasic  
 
  Programming language: WebDNA
 
[!]

WebDNA is a webserver-side language used in
the product of the same name by Smith Micro Software
<http://www.smithmicro.com/>
Code by Rob Marquardt, 5/17/2002

[/!]

<HTML>

[loop start=99&end=0&advance=-1]

[text]bottles=[index] bottle[showif [index]!1]s[/showif][/text]

[hideif [index]=99][bottles] of beer on the wall.<br><br>[/hideif]

[if [index]!0]
[then]
[bottles] of beer on the wall, [bottles] of beer<br>
Take one down, pass it around...<br>
[/then]
[else]
No more bottles of beer on the wall, no more bottles of beer<br>
Go to the store, buy some more...<br>
99 bottles of beer on the wall.
[/else]
[/if]

[/loop]

</HTML>
 
  Programming language: WebL
 
// WebL version of 99 Bottles of beer (Bottles.webl)
// WebL = Compaq's Web Language, http://research.compaq.com/SRC/WebL
// Philipp Winterberg, http://www.winterbergs.de

var b = 99;

while b > 0 do 
  PrintLn(b, " bottle(s) of beer on the wall,\n",	
          b, " bottle(s) of beer.\n", "Take one down, pass it around,\n",
          (b - 1), " bottle(s) of beer on the wall.\n");
  b = b - 1
end

 
  Programming language: Whenever
 
See http://www.dangermouse.net/esoteric/whenever.html

1 defer (4 || N(1)<N(2) && N(2)<N(3)) print(N(1)+" bottles of beer on the wall, "+N(1)+" bottles of beer,");
2 defer (4 || N(1)==N(2)) print("Take one down and pass it around,");
3 defer (4 || N(2)==N(3)) print(N(1)+" bottles of beer on the wall.");
4 1#98,2#98,3#98; 
 
  Programming language: Whitespace
 
Whitespace version of 99	bottles	of beer (Bottles.ws) 2003-04-01		
See http://compsoc.dur.ac.uk/whitespace/ for	details+interpreter
Example by	Andrew	Kemp <ajwk@pell.uklinux.net>
 
(*All*	space/tab/linefeed characters	are	significant!)

 
	

  		




  	 

 		  
   	     
	
     		 				
	
     		  		 
	
     	     
	
     		   	 
	
     		  	 	
	
     		  	 	
	
     			  	 
	
     	     
	
     		 				
	
     		 			 
	
     	     
	
     			 	  
	
     		 	   
	
     		  	 	
	
     	     
	
     			 			
	
     		    	
	
     		 		  
	
     		 		  
	
     	 		  
	
     	 	 
	
  
 		  
   	     
	
     		 				
	
     		  		 
	
     	     
	
     		   	 
	
     		  	 	
	
     		  	 	
	
     			  	 
	
     	 		  
	
     	 	 
	
     	 	 	  
	
     		    	
	
     		 	 		
	
     		  	 	
	
     	     
	
     		 				
	
     		 			 
	
     		  	 	
	
     	     
	
     		  	  
	
     		 				
	
     			 			
	
     		 			 
	
     	     
	
     		    	
	
     		 			 
	
     		  	  
	
     	     
	
     			    
	
     		    	
	
     			  		
	
     			  		
	
     	     
	
     		 	  	
	
     			 	  
	
     	     
	
     		    	
	
     			  	 
	
     		 				
	
     			 	 	
	
     		 			 
	
     		  	  
	
     	 		  
	
     	 	 
	
     	
	  	
 		  
   	     
	
     		 				
	
     		  		 
	
     	     
	
     		   	 
	
     		  	 	
	
     		  	 	
	
     			  	 
	
     	 			 
	
     	 	 
	
     	 	 
	
  
	

  	  
 
    	
	  	 
 
			 	

	 		 
 
 	
 	   	     
	
     		   	 
	
     		 				
	
     			 	  
	
     			 	  
	
     		 		  
	
     		  	 	
	
     			  		
	
  
	

  		 
   		   	
	
     	     
	
     		   	 
	
     		 				
	
     			 	  
	
     			 	  
	
     		 		  
	
     		  	 	
	
  
	

  	 	
 

   	  			 
	
     		 				
	
     	     
	
     		 		 	
	
     		 				
	
     			  	 
	
     		  	 	
	
     	     
	
     		   	 
	
     		 				
	
     			 	  
	
     			 	  
	
     		 		  
	
     		  	 	
	
     			  		
	
  
	

 
  Programming language: WIL
 
; WIL version of 99 Bottles of beer (Bottles.wbt)
; See http://www.winbatch.com/winware/wb-functions.html
; Philipp Winterberg, http://www.winterbergs.de

c = " on the wall"  
a = " bottle(s) of beer"
d = "Take one down, pass it around," 
for b = 1 to 99
  display(2, "", StrCat(100-b,a,c,",",@CRLF,100-b,a,".",@CRLF,d,@CRLF,99-b,a,c,".")) 
next
exit  
 
  Programming language: WinAPI with C++
 
//99 Bottles of Beer by Daniel Hilgarth aka dEUs with the WinAPI
#include <windows.h>
#include <string>
using namespace std;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR 
szCmdLine, int iCmdShow)
{
     MSG         msg;
     HWND        hWnd;
     WNDCLASS    wc;

     const char  szAppName[] = "99 Bottles of Beer";

     wc.cbClsExtra           = 0;
     wc.cbWndExtra           = 0;
     wc.hbrBackground        = (HBRUSH) GetStockObject(WHITE_BRUSH);
     wc.hCursor              = LoadCursor(NULL, IDC_ARROW);
     wc.hIcon                = LoadIcon(NULL, IDI_APPLICATION);
     wc.hInstance            = hInstance;
     wc.lpfnWndProc          = WndProc;
     wc.lpszClassName        = szAppName;
     wc.lpszMenuName         = NULL;
     wc.style                = CS_HREDRAW | CS_VREDRAW;

     RegisterClass(&wc);

     hWnd = CreateWindow(    szAppName,
                             szAppName,
                             WS_OVERLAPPED | WS_SYSMENU,
                             CW_USEDEFAULT,
                             CW_USEDEFAULT,
                             300,
                             470,
                             NULL,
                             NULL,
                             hInstance,
                             NULL);

     ShowWindow(hWnd, iCmdShow);
     UpdateWindow(hWnd);

     while (GetMessage(&msg, NULL, 0, 0))
     {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
     }

     return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static HWND        hButton;
     static HWND        hEdit;

     switch (message)
     {
         case WM_CREATE:
         {
             hButton = CreateWindowEx(BS_PUSHBUTTON,
                                   "button",
                                   "Start",
                                   WS_CHILD | WS_VISIBLE,
                                   0,0,0,0,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -> hInstance,
                                   NULL);
             hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,
                                    "edit",
                                    "",
                                    WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL 
| WS_VSCROLL | ES_MULTILINE,
                                    0, 0, 0, 0,
                                    hWnd,
                                    NULL,
                                    ((LPCREATESTRUCT) lParam) -> hInstance,
                                    NULL);
             int FontSize=-11;
             char FontName[]="Tahoma";
             HFONT MyFont = CreateFont(FontSize, 0, 0, 0, 0, 0, 0, 0, 
ANSI_CHARSET,
             OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
             DEFAULT_PITCH, FontName);
             if (MyFont != 0)
             {
                 SendMessage(hEdit, WM_SETFONT, int(MyFont), true);
                 SendMessage(hButton, WM_SETFONT, int(MyFont), true);
             }
             return 0;
         }
         case WM_SIZE:
         {
             MoveWindow(hButton, LOWORD(lParam) / 2 - 80, 
HIWORD(lParam)-40, 160, 30, TRUE);
             MoveWindow(hEdit, 10, 10, LOWORD(lParam)-20, 
HIWORD(lParam)-60, TRUE);
             return 0;
         }
         case WM_COMMAND:
         {
             if (lParam == (LPARAM)hButton)
             {
                 if (HIWORD(wParam) == BN_CLICKED)
                 {
                     string strBottles;
                     for(int i=99;i>0;--i)
                     {
                         char chTmp[200]="";
                         char chPlural[2]="s";
                         if(i==1)
                             chPlural[0]=0;
                         sprintf(chTmp,"%d bottle%s of beer on the 
wall,\r\n%d bottle%s of beer."
                             "Take one down, pass it 
around,\r\n",i,chPlural,i,chPlural);
                         if(i==1)
                             strcat(chTmp,"No more bottles on the wall.");
                         else
                             sprintf(chTmp,"%s%d bottle%s of beer on the 
wall.\r\n",chTmp,i-1,i==2?"":"s");
                         strBottles+=chTmp;
                     }
                     SetWindowText(hEdit,strBottles.c_str());
                 }
             }
             return 0;
         }
         case WM_DESTROY:
         {
             PostQuitMessage(0);
             return 0;
         }
     }
     return DefWindowProc(hWnd, message, wParam, lParam);
}
 
  Programming language: WinBatch
 
; WinBatch version of 99 Bottles of beer (Bottles.wbt)
; See http://www.winbatch.com/winware/winbatch.html
; Philipp Winterberg, http://www.winterbergs.de

a=" bottle(s) of beer"
b=99   
c=" on the wall"  
d="Take one down, pass it around," 
BoxOpen("99 Bottles of Beer", "")
while b>0
  BoxText (StrCat(b,a,c,",",@CRLF,b,a,".",@CRLF,d,@CRLF,b-1,a,c,"."))
  TimeDelay(2)
  b=b-1     
endwhile
BoxShut()
Exit  
 
  Programming language: Wise InstallMaster8
 
Document Type: WSE
item: Global
  Version=8.1
  Title=99 Bottles of Beer Installation
  Flags=00000100
  Split=1420
  Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  Copy Default=1
  Japanese Font Name=MS Gothic
  Japanese Font Size=9
  Progress Bar DLL=%_WISE_%\Progress\WIZ%_EXE_OS_TYPE_%.DLL
  Start Gradient=0 0 255
  End Gradient=0 0 0
  Windows Flags=00000100000000010010110000001000
  Log Pathname=%MAINDIR%\INSTALL.LOG
  Message Font=MS Sans Serif
  Font Size=8
  Pages Modified=00000001000000000000000000000000
  Disk Label=WiseInst
  Disk Filename=SETUP
  Patch Flags=0000000000000001
  Patch Threshold=85
  Patch Memory=4000
  FTP Cluster Size=20
  Per-User Version ID=1
  Dialogs Version=8
  Crystal Format=10111100101100000010001001001001
  Crystal Destination=00000000000000000000000000001011
  Step View=&Properties
  Variable Name1=_SYS_
  Variable Default1=C:\WINDOWS\System32
  Variable Flags1=00001000
  Variable Name2=_WISE_
  Variable Default2=C:\PROGRA~1\Wise8
  Variable Flags2=00001000
end
item: Remark
  Text=99 Bottles of Beer Song
end
item: Remark
  Text=for Wise InstallMaster 8
end
item: Remark
  Text=2002 Michael Pousen, www.adpag.de
end
item: Open/Close INSTALL.LOG
  Flags=00000001
end
item: Set Variable
  Variable=APPTITLE
  Value=99 Bottles of Beer
  Flags=10000000
end
item: Set Variable
  Variable=MAINDIR
  Value=%TEMP%
  Flags=10000000
end
item: Get Temporary Filename
  Variable=SONG
end
item: Set Variable
  Variable=SONG
  Value=%TEMP%\%SONG%
end
item: Set Variable
  Variable=BOTTLES
  Value=bottles
end
item: Set Variable
  Variable=NUMBER
  Value=99
end
item: If/While Statement
  Variable=NUMBER
  Value=1
  Flags=00010111
end
item: Insert Line into Text File
  Pathname=%SONG%
  New Text=%NUMBER% %BOTTLES% of beer on the wall, %NUMBER% %BOTTLES% of
beer.
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%SONG%
  New Text=Take one down and pass it around,
  Line Number=0
  Flags=00010000
end
item: Set Variable
  Variable=NUMBER
  Value=%NUMBER%
  Flags=00001000
end
item: If/While Statement
  Variable=NUMBER
  Value=1
end
item: Set Variable
  Variable=BOTTLES
  Value=bottle
end
item: End Block
end
item: If/While Statement
  Variable=NUMBER
  Value=0
  Flags=00000001
end
item: Insert Line into Text File
  Pathname=%SONG%
  New Text=%NUMBER% %BOTTLES% of beer on the wall.
  Line Number=0
end
item: End Block
end
item: End Block
end
item: Insert Line into Text File
  Pathname=%SONG%
  New Text=no more bottles of beer on the wall.
  Line Number=0
  Flags=00010000
end
item: Display ReadMe File
  Pathname=%SONG%
  Title=99 Bottles of Beer Song
end
item: Delete File
  Pathname=%SONG%
end
 
  Programming language: Word
 
Sub MAIN
REM "99 bottles of beer on the wall"
REM Microsoft Word WordBasic macro language version
REM written by Mark Pilgrim, f8dy@netaxs.com
FileNew
beer$ = "99"
bottle$ = " bottles "
For  count = 99 To 1 Step - 1
  Insert beer$ + bottle$ + "of beer on the wall,"
  InsertPara
  Insert beer$ + bottle$ + "of beer,"
  InsertPara
  Insert "Take "
  If count > 1 Then
    Insert "one"
  Else
    Insert "it"
  End If
  Insert " down, pass it around,"
  InsertPara
  If count > 1 Then
    beer$ = Str$(count - 1)
    beer$ = Right$(beer$, Len(beer$) - 1)
    If count = 2 Then bottle$ = " bottle "
    Insert beer$ + bottle$ + "of beer on the wall."
    InsertPara
  Else
    Insert "No more bottles of beer on the wall."
  End If
  InsertPara
Next
End Sub
 
  Programming language: WordBasic
 
' Word Basic version of 99 bottles of beer
' by Cory Sandahl (sandahl@u.washington.edu) 12/10/96

Sub MAIN

FileNew .NewTemplate = 1, .Template = "Normal.DOT"
StartOfDocument
s$ = "s"

For NumberOfBeers = 99 To 1 Step - 1

    Insert Str$(NumberOfBeers) + " bottle" + s$ + " of beer on the wall," + Chr$(11)
    Insert Str$(NumberOfBeers) + " bottle" + s$ + " of beer..." + Chr$(11)
    Insert "Take one down, pass it around," + Chr$(11)
    
    If (NumberOfBeers - 1) < 2 Then
        s$ = ""
    End If

    Insert Str$(NumberOfBeers - 1) + " bottle" + s$ + " of beer on the wall. " + Chr$(11) + Chr$(11)

Next
Insert Chr$(11) + Chr$(11) + "No more beer.  Bye-bye."

End Sub
 
  Programming language: WoS Quest Script
 
Quest is the scripting language for an online multiplayer RPG (Well of Souls)
By Dan Samuel, 29.4.2002

@BeerSong
ACTOR 1, "Drunk", <Josh's drunken guy skin>
SET bottles, 99
@loop
1: #<bottles> bottles of beer on the wall.
1: #<bottles> bottles of beer.
1: Take one down, pass it around.
SUB bottles, 1
IF= @done
1: #<bottles> bottles of beer on the wall.
WAIT .5
GOTO loop
@done
1: Buuuuuuuurp!

 
  Programming language: wxBasic
 
// wxBasic version of 99 Bottles of beer (Bottles.wx)
// See http://wxbasic.sourceforge.net/
// Philipp Winterberg, http://www.winterbergs.de

a$=" bottle(s) of beer" : A$= a$ + " on the wall"
B$=".\nTake one down, pass it around,\n"
for b = 99 to 1 step -1
  ? b; A$; ",\n"; b; a$; B$; b-1; A$; ".\n"
next
 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:32