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
GABasic   GAP   GASP   GBasic   GBD   Gema   Genesis 2   GFA Basic (for Windows)   GFA Basic   GLPRO   Glulxa   GNU Assembler   GNU CPP   GNU find   GNU Make   Gofer   goo   GPLZ easy   GProlog   GrASP   gri   GRIP   GTML   GWScript  
 
  Programming language: GABasic
 
' GABasic version of 99 Bottles of beer (Bottles.bas)
' See http://mitglied.lycos.de/movaxworldhq/basic.htm
' Philipp Winterberg, http://www.winterbergs.de

cls
for b = 99 to 1 step -1
  temp = b - 1
  print " "
  print str$(b) + " bottle(s) of beer on the wall,"
  print str$(b) + " bottle(s) of beer."
  print "Take one down, pass it around,"
  print str$(temp) + " bottle(s) of beer  on the wall."
next
sleep
 
  Programming language: GAP
 
#########################################################################
# BottlesOfBeer.g by Mike Hoolehan (mike@sycamorehq.com)
# for GAP (http://www-groups.dcs.st-andrews.ac.uk/~gap/)
# this is a really silly way to do it, but I want to show off some GAP
# Jan 5, 2002
#########################################################################
NumBottles := 99;;
BottleRing := ZmodnZ(NumBottles+1);;
BottleGenerator := GeneratorsOfRing(BottleRing)[1];;

for i in Reversed([1..Size(BottleRing)-1]) do
    CurrentBottles:=Int(i*BottleGenerator);
    Print(CurrentBottles, " bottle(s) of residue class beer on the wall.\n");
    Print(CurrentBottles, " bottle(s) of residue class beer.\n");
    Print("Take one down, reduce the power of the ring generator.\n");
    Print(CurrentBottles-1, " bottle(s) of beer on the wall.\n\n");
od
 
  Programming language: GASP
 
.PROGRAM  gasp version of 99 bottles of beer
.PROGRAM  Laurent Vogel  http://lvogel.free.fr
.PROGRAM
i .ASSIGNA 99
s .ASSIGNC "s"
.AREPEAT \&i
 \&i bottle\&s of beer on the wall,
 \&i bottle\&s of beer.
 Take one down, pass it around,
i .ASSIGNA \&i-1
.AIF \&i LE 1
s .ASSIGNC ""
.AIF \&i EQ 0
i .ASSIGNC "No"
.AENDI
.AENDI
 \&i bottle\&s of beer on the wall.
 \( )
.AENDR
.END
 
  Programming language: GBasic
 
REM GBasic version of 99 Bottles of beer (Bottles.b)
REM See http://mitglied.lycos.de/movaxworldhq/basic.htm
REM Philipp Winterberg, http://www.winterbergs.de

color(255, 0) : screen 13
for b = 99 to 1 step -1 : print
  print str$(b) + " bottle(s) of beer on the wall,"
  print str$(b) + " bottle(s) of beer."
  print "Take one down, pass it around,"
  print str$(b-1) + " bottle(s) of beer  on the wall."
next : wait_key
 
  Programming language: GBD
 
# GBD command version of 99 bottles of beer
# Laurent Vogel,  http://lvogel.free.fr
#
# run as:  gdb --batch -nw --command=THIS_FILE

printf "99 bottles of beer on the wall,\n"
printf "99 bottles of beer.\n"

set $i = 99

define loop
set $i = $i-1
printf "Take one down, pass it around,\n"
printf "%d bottles of beer on the wall.\n\n", $i
printf "%d bottles of beer on the wall,\n", $i
printf "%d bottles of beer.\n", $i
end

define loop2
loop
loop
loop
loop
end

define loop3
loop2
loop2
loop2
loop2
end

loop3
loop3
loop3
loop3
loop3
loop3
loop

printf "Take one down, pass it around,\n"
printf "1 bottle of beer on the wall.\n\n"
printf "1 bottle of beer on the wall,\n"
printf "1 bottle of beer.\n"
printf "Take one down, pass it around,\n"
printf "No bottle of beer on the wall.\n"
 
  Programming language: Gema
 
! gema version of 99 bottles of beer
! Laurent Vogel  http://lvogel.free.fr
! (gema info  http://www.ugcs.caltech.edu/gema/)

@set{i;99}@set{s;s}@set{b; bottle}@set{o; of beer}@set{w; on the wall}
@repeat{$i;@out{$i$b$s$o$w,\n$i$b$s$o.\n}\
@out{Take one down, pass it around,\n}@decr{i}\
@set{s;@cmpn{$i;1;;;s}}@set{i;@cmpn{$i;1;No;$i;$i}}\
@out{$i$b$s$o$w.\n\n}}@end
 
  Programming language: Genesis 2
 
<!--# Genesis 2 template language.
  Genesis 2 is a web publishing system. For more information see
  http://www.genesis2.cz/
  Example of this beast at work: http://help.genesis2.cz/beer99.html
#-->
<!--*MIME ContentType="text/plain"*-->
<!--*CYKLUS pocatek=99 konec=1 krok=-1
%hodnota bottles of beer on the wall,
%hodnota bottles of beer,
Take one down pass it around,
%FUNC_VYRAZ(%hodnota-1) bottles of beer on the wall.

*-->
 
  Programming language: GFA Basic (for Windows)
 
// GFA Basic for Windows version of 99 Bottles of beer (Bottles.gfw)
// See http://www.beepcastle.de/gfa/index.htm#trial
// Philipp Winterberg, http://www.winterbergs.de

OPENW #1
b = 99
WHILE b > 0
  ? b; " bottle(s) of beer on the wall,"
  ? b; " bottle(s) of beer."
  ? "Take one down, pass it around,"
  b--
  ? b; " bottle(s) of beer on the wall."; CHR$(13,10)
WEND
KEYGET a%
CLOSEW #1
QUIT
 
  Programming language: GFA Basic
 
// GFA Basic version of 99 Bottles of beer (Bottles.gfa)
// See http://www.baphead.freeserve.co.uk/download.html
// Philipp Winterberg, http://www.winterbergs.de

SCREEN 18
CLS
b := 99
WHILE b > 0
  ? b; " bottle(s) of beer on the wall,"
  ? b; " bottle(s) of beer."
  ? "Take one down, pass it around,"
  b--
  ? b; " bottle(s) of beer on the wall."
  ?
WEND
 
  Programming language: GLPRO
 
; Script 99bottles.gls
; Last modified by Rainer at 08.06.2002 15:57:09
; 99bottles@RainerBrang.de
; http://www.rainerbrang.de
;"Rest in peace, GLPRO".

;GLPRO Version of 99 bottles of beer

        ; black window, white text
        drawCLEAR 0 0 0 
        color white
 
        ; scroll text when reaching the end of the window
        set textSCROLL ON
 
        ; count down from 99 and do stuff
        beginLOOP 99 1 -1
                text @loop$" bottle(s) of beer on the wall, "@loop$" bottle(s) of beer"@crlf
                text "Take one down and pass it around,"@crlf
                text (@loop-1)$" bottle(s) of beer on the wall"@crlf
        endLOOP
 
        ; wait for any key
        waitKEY
 
  Programming language: Glulxa
 
;  Glulxa version of 99 bottles of beer
;  Laurent Vogel,  http://lvogel.free.fr
;  Glulx toolcase found at http://www.plover.net/~jaybird/glulx.zip

stack 256
ext 1024

section code

:main   dc.b 0xc0 0x00 0x00
        copy 0x01.l (sp) 
        copy 0x03.l (sp)
        copy 0x00.l (sp) 
        copy 0x00.l (sp) 
        copy 0x00.l (sp) 
        glk 0x23.b 0x05.b (:glk_winnum).l
        copy (:glk_winnum).l (sp)
        glk 0x2f.b 0x01.b (:glk_result).l

        copy 99 (:n).l
:loop   call :p.l 0 0
        call :w.l 0 0
        streamchar 0x2c
        streamchar 0x0a
        call :p.l 0 0
        streamchar 0x2e
        streamchar 0x0a
        streamchar 0x54
        streamchar 0x61
        streamchar 0x6b
        streamchar 0x65
        streamchar 0x20
        streamchar 0x6f
        streamchar 0x6e
        streamchar 0x65
        streamchar 0x20
        streamchar 0x64
        streamchar 0x6f
        streamchar 0x77
        streamchar 0x6e
        streamchar 0x2c
        streamchar 0x20
        streamchar 0x70
        streamchar 0x61
        streamchar 0x73
        streamchar 0x73
        streamchar 0x20
        streamchar 0x69
        streamchar 0x74
        streamchar 0x20
        streamchar 0x61
        streamchar 0x72
        streamchar 0x6f
        streamchar 0x75
        streamchar 0x6e
        streamchar 0x64
        streamchar 0x2c
        streamchar 0x0a
        sub (:n).l 1 (:n).l
        call :p.l 0 0
        call :w.l 0 0
        streamchar 0x2e
        streamchar 0x0a
        streamchar 0x0a
        jnz (:n).l :loop.l     
        quit

:w      dc.b 0xc0 0x00 0x00
        streamchar 0x20
        streamchar 0x6f
        streamchar 0x6e
        streamchar 0x20
        streamchar 0x74
        streamchar 0x68
        streamchar 0x65
        streamchar 0x20
        streamchar 0x77
        streamchar 0x61
        streamchar 0x6c
        streamchar 0x6c
        return 0
        
:p      dc.b 0xc0 0x00 0x00
        jnz (:n).l :nz.l
        streamchar 0x4e
        streamchar 0x6f
        streamchar 0x20
        streamchar 0x6d
        streamchar 0x6f
        streamchar 0x72
        streamchar 0x65
        jump :bot
:nz     streamnum (:n).l
:bot    streamchar 0x20
        streamchar 0x62
        streamchar 0x6f
        streamchar 0x74
        streamchar 0x74
        streamchar 0x6c
        streamchar 0x65
        jeq (:n).l 1 :one.l
        streamchar 0x73
:one    streamchar 0x20
        streamchar 0x6f
        streamchar 0x66
        streamchar 0x20
        streamchar 0x62
        streamchar 0x65
        streamchar 0x65
        streamchar 0x72
        return 0
        
section vdata
:n      ds.l 1
:glk_winnum ds.l 1
:glk_result ds.l 1
 
  Programming language: GNU Assembler
 
/*
 * GNU Assembler version of 99 bottles of beer
 * (architecture-independent as it uses assembler directives only)
 * Laurent Vogel  http://lvogel.free.fr
 *
 * execute with: gcc -c -o /dev/null -x assembler THIS_FILE
 */

.macro p n,s,w
.print "\n bottle\s of beer\w"
.endm

.macro ones a,b
.ifge \a\b-2
.ifnc \a\b,99
p \a\b,s,"on the wall."
.print ""
.endif
p \a\b,s,"on the wall,"
p \a\b,s,.
.else
p \a\b,,"on the wall."
.print ""
p \a\b,,"on the wall,"
p \a\b,,.
.endif
.print "Take one down, pass it around,"
.endm

.macro tens n
ones \n,9
ones \n,8
ones \n,7
ones \n,6
ones \n,5
ones \n,4
ones \n,3
ones \n,2
ones \n,1
.ifnc \n,
ones \n,0
.endif
.endm

tens 9
tens 8
tens 7
tens 6
tens 5
tens 4
tens 3
tens 2
tens 1
tens ""

p No,,"on the wall."
 
  Programming language: GNU CPP
 
/************************************************************************/
/*	bottle.cpp							*/
/*	1996 Walter Zimmer (walter.zimmer@rz.uni-ulm.de)		*/
/*									*/
/*	Save as "bottle.cpp" or change all the #includes !		*/
/*	#include is necessary since cpp expands each line into		*/
/*	no more than one new line					*/
/*									*/
/*	Invocation: cpp -P bottle.cpp					*/
/*									*/
/*	Remove comments to have less empty lines in the output		*/
/*	but we still have to many...					*/
/************************************************************************/

#if defined TEXT
/* This is the part which outputs one verse. 'Passed' parameters are */
	/* ONES:	inner digit */
	/* TENS:	outer digit */
	/* SECONDTEN:	outer digit decremented by one */

	/* if ONES == 0 then we have to use the decremented outer digit */
	#if ONES == 0
		/* omit output of 00 verse */
		#if SECONDTEN < 10
		/* Use SECONDTEN */
			print(TENS,ONES)
			print(TENS,ONES)
			  Take one down, pass it around
			print(SECONDTEN,SECONDONE)
		#endif /* SECONDTEN */
	#else /* ONES */
		/* Here everthing is normal, we use the normal TENS */
			print(TENS,ONES)
			print(TENS,ONES)
			  Take one down, pass it around
			print(TENS,SECONDONE)
	#endif /* ONES */
#elif defined LOOP
/*	This is the inner loop which iterates about the last digit */
	/* #undef LOOP, #define TEXT so we output text in the next #include */
	#undef LOOP
	#define TEXT

	/* #undef and #define the inner digits, invoke text output */
	#undef ONES
	#undef SECONDONE
	#define ONES 9
	#define SECONDONE 8
	#include "bottle.cpp"

	/* ...and so on for digits 8-0 */
	#undef ONES
	#undef SECONDONE
	#define ONES 8
	#define SECONDONE 7
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 7
	#define SECONDONE 6
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 6
	#define SECONDONE 5
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 5
	#define SECONDONE 4
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 4
	#define SECONDONE 3
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 3
	#define SECONDONE 2
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 2
	#define SECONDONE 1
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 1
	#define SECONDONE 0
	#include "bottle.cpp"
	#undef ONES
	#undef SECONDONE
	#define ONES 0
	#define SECONDONE 9
	#include "bottle.cpp"

	/* Clean up */
	#undef TEXT

#else /* TEXT, LOOP */
/*	Here is the basic 'loop' which iterates about the outer digit */

	/* First define the print macro which outputs one line of xx beer */
	/* We have to define it over the second define 'raw' to combine */
	/* prescan with concatenation */
	#define raw(TENS,ONES) TENS ## ONES
	#define print(TENS,ONES) raw(TENS,ONES) bottles of beer on the wall

	/* Tell bottle.cpp to invoke the inner loop when #included */
	#define LOOP

	/* #define outer digit and process inner loop */
	#define TENS 9
	#define SECONDTEN 8
	#include "bottle.cpp"

	/* Do this for the other digits 8 to 0, now with #undef */
	/* Since LOOP gets #undef'd, we have to define it again */
	#define LOOP
	#undef TENS
	#define TENS 8
	#undef SECONDTEN
	#define SECONDTEN 7
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 7
	#undef SECONDTEN
	#define SECONDTEN 6
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 6
	#undef SECONDTEN
	#define SECONDTEN 5
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 5
	#undef SECONDTEN
	#define SECONDTEN 4
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 4
	#undef SECONDTEN
	#define SECONDTEN 3
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 3
	#undef SECONDTEN
	#define SECONDTEN 2
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 2
	#undef SECONDTEN
	#define SECONDTEN 1
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 1
	#undef SECONDTEN
	#define SECONDTEN 0
	#include "bottle.cpp"
	#define LOOP
	#undef TENS
	#define TENS 0
	#undef SECONDTEN

	/* We @define SECONDTEN as 10 to indicate that we are outputting */
	/* the last block and therefore need only 9 verses */
	#define SECONDTEN 10
	#include "bottle.cpp"
#endif
 
  Programming language: GNU find
 
# By Peter Maydell: http://www.chiark.greenend.org.uk/~pmaydell/find/beerhack

#!/bin/sh
#
# 99 Bottles Of Beer - find(1) version (with a little help from its 
# friends: mkdir, cd, sh, expr, ls, echo and rm)
# Copyright (C) Peter Maydell <pmaydell@chiark.greenend.org.uk>
#
# This shell script is just a wrapper to tidy up after the find
# command which does all the real work...
# 
# You might want to change the 99 to 10 to get less output :->

mkdir /tmp/beer || exit 1
cd /tmp/beer

find . -noleaf \
-path . \
	-exec mkdir 99 \; \
-o -name 1 \
	-printf '1 bottle of beer on the wall, 1 bottle of beer\nTake' \
	-printf 'one down and pass it around\nNo bottles of beer!\n' \
-o \
	-exec sh -c "mkdir {}/\`expr {} : '.*/\(.*\)' - 1\`" \; \
	-printf '%f bottles of beer on the wall, %f bottles of beer\n' \
	-printf 'Take one down and pass it around, ' \
	-exec sh -c "echo -n \`ls {}\`" \; \
	-printf ' bottle' \
	-name 2 \
		-printf ' of beer\n' \
	-o \
		-printf 's of beer\n'

cd /tmp
rm -rf /tmp/beer

# You will need the following programs. I have listed which versions
# I have, and that combination has been tested. Others might work...
# mkdir   : any old mkdir should do; mine is from GNU fileutils 3.16
# cd      : only used in the pre and post-party stuff, any old cd will do
# find    : I used GNU find version 4.1; if your find doesn't have the
#           -noleaf option then it probably doesn't have the optimisation
#           that flag disables; try just omitting it
# sh      : I used bash version 2.01.1(1)-release, but have tried not
#           to use bash-isms. Must be a Bourne-like shell, though.
# expr    : expr from GNU shellutils 1.16
# ls      : ls from GNU fileutils 3.16; any will do provided that 
#           'ls directory' for a dir. with a single subdirectory and nothing
#           else in it prints only the subdir name.
# echo    : I used the bash builtin. You need an echo that understands the
#           -n flag (meaning, don't print trailing newline). Actually, this is
#           just so the output looks nice, and you can omit the -n.
# rm      : from GNU fileutils 3.16; any should do, and it's only used
#           to tidy up a bit. 
 
  Programming language: GNU Make
 
# Makefile to sing the infamous 99 Bottles of Beer song, without resorting
# to ugly shell escapes for the math :)

# Author: Phil Ashby (phlash@ashbysoft.com)
# Date: 30/Jan/2002

# Inital values of digits.. (mostly overridden on command line)
UNITS=9
TENS=9

.SILENT:

# GNU make can do math using conditionals!
NTENS=$(TENS)
ifeq "$(UNITS)" "9"
NUNITS=8
endif
ifeq "$(UNITS)" "8"
NUNITS=7
endif
ifeq "$(UNITS)" "7"
NUNITS=6
endif
ifeq "$(UNITS)" "6"
NUNITS=5
endif
ifeq "$(UNITS)" "5"
NUNITS=4
endif
ifeq "$(UNITS)" "4"
NUNITS=3
endif
ifeq "$(UNITS)" "3"
NUNITS=2
endif
ifeq "$(UNITS)" "2"
NUNITS=1
endif
ifeq "$(UNITS)" "1"
NUNITS=0
	ifeq "$(TENS)" "0"
	NTENS=STOP
	endif
endif
ifeq "$(UNITS)" "0"
NUNITS=9
	ifeq "$(TENS)" "9"
	NTENS=8
	endif
	ifeq "$(TENS)" "8"
	NTENS=7
	endif
	ifeq "$(TENS)" "7"
	NTENS=6
	endif
	ifeq "$(TENS)" "6"
	NTENS=5
	endif
	ifeq "$(TENS)" "5"
	NTENS=4
	endif
	ifeq "$(TENS)" "4"
	NTENS=3
	endif
	ifeq "$(TENS)" "3"
	NTENS=2
	endif
	ifeq "$(TENS)" "2"
	NTENS=1
	endif
	ifeq "$(TENS)" "1"
	NTENS=0
	endif
	ifeq "$(TENS)" "0"
	NTENS=STOP
	endif
endif

# default target..
stanza: 
	@echo $(TENS)$(UNITS) bottles of beer on the wall $(TENS)$(UNITS) bottles of beer.
	@echo Take one down, pass it around..
ifeq "$(NTENS)" "STOP"
	@echo No more beer.
else
	@echo $(NTENS)$(NUNITS) bottles of beer.
	@echo .
	$(MAKE) -f makefile.bob UNITS=$(NUNITS) TENS=$(NTENS)
endif
 
  Programming language: Gofer
 
Gofer is a variation of Haskell. 
<a href=http://www.cs.yale.edu/HTML/YALE/CS/haskell/yale-fp.html>More Information</a>

-- 99 bottles of beer (gofer version)
-- Written by Bow-Yaw Wang (bywang@saul.cis.upenn.edu)

radix 0 _ = []
radix x n = (x `mod` n):(radix (x/n) n)

itoa x = map (\x -> chr(x + ord('0'))) (reverse (radix x 10))

bottles :: Int -> Dialogue

bottles 1 resps = [AppendChan stdout "1 bottle of beer on the wall, ",
                   AppendChan stdout "1 bottle of beer.\n",
                   AppendChan stdout "Take one down, pass it around, ",
                   AppendChan stdout "no more bottles of beer on the wall.\n"]
bottles n resps = [AppendChan stdout (itoa n),
                   AppendChan stdout " bottles of beer on the wall, ",
                   AppendChan stdout (itoa n),
                   AppendChan stdout " bottles of beer.\n",
                   AppendChan stdout "Take one down, pass it around, ",
                   AppendChan stdout (itoa (n-1)),
                   AppendChan stdout " bottles of beer on the wall.\n"] ++
                   bottles (n-1) resps
 
  Programming language: goo
 
; GOO version of 99 bottles of beer
; by Juri Pakaste <juri@iki.fi>
; GOO information at http://www.googoogaga.org/

(df bottles (n)
        (cat
                (cond ((= n 0) "No more bottles")
                        ((= n 1) "One bottle")
                        (#t (cat (num-to-str n) " bottles")))
        " of beer"))

(df bow (n)
        (cat (bottles n) " on the wall"))

(do 
        (fun (n) 
                (post (bow n)) 
                (post "\n") 
                (post (bottles n)) 
                (post "\nTake one down, pass it around\n") 
                (post (bow (1- n))) 
                (post "\n\n")) 
        (range-by 100 >= 1 1-))
 
  Programming language: GPLZ easy
 
# GPLZ.easy version of 99 Bottles of beer (Bottles.easy)
# See http://www.p-nand-q.com/gplz/gplz-easy.htm
# Philipp Winterberg, http://www.winterbergs.de

f(x):<<x." bottle(s) of beer on the wall,"
g(x):<<x.<<" bottle(s) of beer."
h(x):<<"Take one down, pass it around,"
i(x):<<x-1.<<" bottle(s) of beer on the wall."
j(x):<<" "
do:b=99
while:b>0.f(b).g(b).h(b).i(b).j(i).b=b-1
 
  Programming language: GProlog
 
/*******************************************************
 * 99 Bottles of Beer
 * Paul J. DeMarco  9/20/2002
 * beer.pro
 * To execute start gprolog (others may work)
 * consult('beer.pro').
 * drink(beer,99).
 *******************************************************/
english(beer,0):-
                        write('no more bottle of beer').
english(beer,1):-
                        write('1 bottle of beer').
english(beer,X):-
                        X >= 2,
                        write( X ) ,
                        write(' bottles of beer').
 
drink(beer,X):- X >= 1,
                        english(beer,X),
                        write(' on the wall, '),
                        english(beer,X),
                        write(', take one down, pass it around\n'),
                        X1 is X - 1,
                        english(beer,X1),
                        write(' on the wall.\n'),
                        drink(beer, X1).
 
  Programming language: GrASP
 
GrASP is used for controlling the GrASP animation program.

video 1
local var1 99
local var2 24
mark 98
text 1 @var2 @var1
text " bottle(s) of beer on the wall,"
text 1 @var2-1 @var1
text " bottle(s) of beer!"
text 1 @var2-2 "Take one down, pass it around,"
text 1 @var2-3 @var1-1
text " bottle(s) of beer on the wall!"
waitkey 500
set var1 @var1-1
loop
 
  Programming language: gri
 
#!/usr/local/bin/gri
#
# 99 bottles of beer in the graphics language Gri
# Prints out 99BoB to both stdout and also the the postscript file 99BoB.ps
#
# Gri is available from http://gri.sourceforge.net/
#
# beer.gri by Stuart Prescott 2003
#
# Invocation:
#           gri beer.gri
# or just
#           ./beer.gri

\singular   = "bottle"
\plural     = "bottles"
\beer       = "of beer"
\wall       = "\beer on the wall"
\take       = "Take one down and pass it around,"

#set up the postscript file and the font size for the printout
set postscript filename 99BoB.ps
set font size 0.08 cm
.leftmargin. = 3
.bottommargin. = 29
.linewidth. = 0.10
.vertposition. = .bottommargin.

#now generate the song line-by-line
.count. = 100
while {rpn .count. 0 <}         #note: reverse polish notation maths...
  if {rpn .count. 2 ==}
    \bottle1 = "\plural"
    \bottle2 = "\singular"
  else if {rpn .count. 1 ==}
    \bottle1 = "\singular"
    \bottle2 = "\plural"
  else
    \bottle1 = "\plural"
    \bottle2 = "\plural"
  end if

  sprintf \line1 "%.0f \bottle1 \wall, %.0f \bottle1 \beer" .count. .count.
  sprintf \line2 "\take %.0f \bottle2 \wall." {rpn .count. 1 -}

  #Print the line of the song to stdout
  show "\line1"
  show "\line2"
  show ""

  #Print the line of the song to the postscript file
  draw label "\line1" at .leftmargin. .vertposition. cm
  draw label "\line2" at .leftmargin. {rpn .vertposition. .linewidth. -} cm
  .vertposition. = {rpn .vertposition. 2.5 .linewidth. * -}

  .count. -= 1
end while
 
  Programming language: GRIP
 
$$ GRIP is a scripting language for the Unigraphics CAD system.
NUMBER/ n
DO/loop1:,n,0,98
PRINT/istr(99-n)+' Bottles of beer on the wall'
PRINT/istr(99-n)+' Bottles of beeeer'
PRINT/'Take one down, pass it around'
IFTHEN/n==98
	PRINT/'No bottles of beer on the wall'
ELSE/
	PRINT/istr(98-n)+' Bottles of beer on the wall'
ENDIF/
loop1:
PRINT/'No bottles of beer on the wall'
PRINT/'No bottles of beeeer'
PRINT/'Go to the store and buy some more'
PRINT/'No bottles of beer on the wall'
HALT/
 
  Programming language: GTML
 
#if a != a
  GTML version of 99 bottles of beer
  Laurent Vogel, http://lvogel.free.fr
  (GTML info  http://www.lifl.fr/~beaufils/gtml/)

execute as: cp THIS_FILE foo.gtm; gtml -Dcr='
' foo.gtm ; cat foo.html
#endif
#define p(a,s,d) a bottles of beerd<<cr>>
#define w on the wall
#define t take one down, pass it around,<<cr>>
#define u(j,s) <<p(j,s," <<w>>.")>><<cr>>\
<<p(j,s," <<w>>,")>><<p(j,s,.)>><<t>>
#define b(a) <<u(a8,s)>><<u(a7,s)>><<u(a6,s)>><<u(a5,s)>><<u(a4,s)>>\
<<u(a3,s)>><<u(a2,s)>>
#define c(a) <<u(a9,s)>><<b(a)>><<u(a1,s)>><<u(a0,s)>>
<<p(99,s," <<w>>,")>><<p(99,s,.)>><<t>><<b(9)>><<u(91,s)>><<u(90,s)>>\
<<c(8)>><<c(7)>><<c(6)>><<c(5)>><<c(4)>><<c(3)>><<c(2)>><<c(1)>>\
<<b("")>><<u(1,"")>><<p(No,," <<w>>.")>>
 
  Programming language: GWScript
 
// GWScript (GWS) is a C-like scripting language used in (load) testing,
// quality assurance and service level management.
// This piece of code uses Windows Notepad as an "output device".

// Author: Timo Boll, Geyer und Weinig GmbH
// Homepage: http://www.gwtel.de

main () {
  int l_bottle_cnt;
  
  if (execcmd( sysgetenv( "windir" ) + "\\notepad.exe", 512 + 5 ) > 0) {
    for (l_bottle_cnt = 99; l_bottle_cnt > 0; l_bottle_cnt --) {
      kputs( strform( "%d bottle(s) of beer on the wall,\r", l_bottle_cnt ));
      kputs( strform( "%d bottle(s) of beer.\r", l_bottle_cnt ));
      kputs( "Take one down, pass it around,\r" );
      kputs( strform( "%d bottle(s) of beer on the wall.\r\r", l_bottle_cnt - 1 ));
    }
  }
}
 
  © Oliver Schade <os@ls-la.net>, Generated: 06.06.2003 17:38:32