PAL is Prodigy Application Language. I listed this one as unique simply
because you don't often get a peek at a truly proprietary language.
This can't be compiled by anyone other than Prodigy employees.
/*=========================================================================*/
/* */
/* PRODIGY SERVICES COMPANY */
/* */
/* Author: Kim Moser (kmoser@prodigy.com) */
/* Application: 99 Bottles of Beer on the Wall */
/* Program Name: XXXXBEER.PGM */
/* Program Type: Element preprocessor */
/* File Name: xxxxbeer.s */
/* Version: 0.0 */
/* Contents: PAL */
/*=========================================================================*/
/* PROGRAM DESCRIPTION: This function fills PEVs 10-110 with 99 verses */
/* of the "99 Bottles of Beer on the Wall" song (one verse per PEV), */
/* appends these verses to the file whose name was given in P1 (the */
/* first parameter), then opens a window warning you to buy more beer. */
/* */
/* The program is smart enough to pluralize "beer" when refering to */
/* more than one, and says "no" when refering to 0 bottles. */
/* */
/* The output is as follows: */
/* 99 bottles of beer on the wall, 99 bottles of beer. */
/* Take one down, pass it around, 98 bottles of beer on the wall. */
/* ... */
/* 1 bottle of beer on the wall, 1 bottle of beer. */
/* Take one down, pass it around, no bottles of beer on the wall. */
/* Time to buy more beer! */
/* */
/*-------------------------------------------------------------------------*/
/* MAINTENANCE LOG: */
/* PROGRAMMER DATE DESCRIPTION OF CHANGE */
/* Kim Moser 23-Oct-96 Creation. */
/*=========================================================================*/
#define DISPLAY_PEV 10
#define Q_CTX_NAME "beer_ctx"
context beer_ctx {
var
ctx_fp, /* File pointer: where to write the song */
ctx_bottle, /* " bottle" */
ctx_bottle_of_beer, /* " bottle of beer" */
ctx_bottles_of_beer, /* " bottles of beer" */
ctx_on_the_wall; /* " on the wall" */
}
#define DEFAULT_FNAME "beer.txt"
"XXXXBEERPGM\00\0C"(var fname)
{
var i;
var of_beer;
var sentence;
if (open_one_context(Q_CTX_NAME) > 1) {
/* Error opening context */
return (-1);
}
/* Initialize context: */
/* Reduce string overhead by putting these phrases in variables: */
of_beer = " of beer";
ctx_bottle = " bottle";
ctx_bottle_of_beer = string(ctx_bottle, of_beer);
ctx_bottles_of_beer = string(ctx_bottle, "s", of_beer);
ctx_on_the_wall = " on the wall";
if (fname ==$ "") {
/* No filename specified */
fname = DEFAULT_FNAME;
}
if (open(fname, F_APPEND, ctx_fp) == 0) {
for (i=99; i > 0; i-=1) {
sentence = bottles_sentence(i);
&0[DISPLAY_PEV + (100-i)] = sentence;
write_line(ctx_fp, sentence);
}
write_line(ctx_fp, "Time to buy more beer!\n");
close(ctx_fp);
}
close_all_contexts(Q_CTX_NAME);
open_window("XXXXBEERWND\00\0E"); /* Warning: Time to buy more beer */
}
bottles_sentence(var n_bottles)
{
var bob1, bob2; /* " bottles of beer" or " bottle of beer" */
bob1 = bob(n_bottles);
bob2 = bob(n_bottles - 1);
return (
string(
n_bottles,
bob1,
ctx_on_the_wall,
", ",
n_bottles,
bob1,
".\nTake one down, pass it around, ",
(n_bottles-1 ? n_bottles-1 : "no"),
bob2,
ctx_on_the_wall,
"."
)
);
}
bob(var n_bottles)
{
return (n_bottles==1 ? ctx_bottle_of_beer : ctx_bottles_of_beer);
}
Here's a version of 99 bottles in Parrot assembler
(http://www.parrotcode.org/)
# parameterized bottles on the wall
# Jonathan Scott Duff duff@pobox.com
#
# If arguments are given on the command line, the first is how
# many bottles (defaults to 99), and the second is of what
# (defaults to beer).
.macro print4 (a,b,c,d)
print .a
print .b
print .c
print .d
.endm
set I0, P0[1] # how many
set S0, P0[2] # of what?
ne S0, "", BOTCHK
set S0, "beer"
BOTCHK:
gt I0, 0, N_BOTTLES # make sure the count > 0
set I0, 99
N_BOTTLES:
.print4(I0," bottles of ",S0," on the wall,\n")
.print4(I0," bottles of ",S0,",\n")
print "Take one down, pass it around,\n"
dec I0
lt I0, 2, ONE_BOTTLE
.print4(I0," bottles of ",S0," on the wall.\n\n")
branch N_BOTTLES # keep on drinking
ONE_BOTTLE:
.print4(I0," bottle of ",S0," on the wall.\n\n")
.print4(I0," bottle of ",S0," on the wall,\n")
.print4(I0," bottle of ",S0,",\n")
print "Take one down, pass it around,\n"
.print4("No more bottles of ",S0," on the wall.\n\n", "")
print "*Buuurrp*\n"
end
# THE END
(* Pascal version of 99 Bottles of beer *)
program BottlesOfBeers(input, output);
var
bottles: integer;
begin
bottles := 99;
repeat
WriteLn(bottles, ' bottles of beer on the wall, ',
bottles, ' bottles of beer.');
Write('Take one down, pass it around, ');
bottles := bottles-1;
WriteLn(bottles, ' bottles of beer on the wall.');
until (bottles = 1);
WriteLn('1 bottle of beer on the wall, one bottle of beer.');
WriteLn('Take one down, pass it around,'
' no more bottles of beer on the wall')
end.
{ PascalX [English] version of 99 Bottles of beer (Bottles.pas) }
{ See http://www.readyideas.com/pascalx.htm for more infos }
{ Philipp Winterberg, http://www.winterbergs.de }
program Bottles; var b: bigint; a, c: string[20];
begin
a:= ' bottle(s) of beer'; c:= ' on the wall';
for b:=99 downto 1 do
writeln(b, a, c, ', '+chr(13)+chr(10), b, a, '.'+
chr(13)+chr(10)+'Take one down, pass it around,'+
chr(13)+chr(10),(b-1),a,c,'.'+chr(13)+chr(10))
end.
{ PascalX [Portuguese] version of 99 Bottles of beer (Bottles.pas) }
{ See http://www.readyideas.com/pascalx.htm }
{ Philipp Winterberg, http://www.winterbergs.de }
PROGRAMA Bottles;
VAR b: BIGINT; a, c: STRING[20];
INICIO
a:= ' bottle(s) of beer'; c:= ' on the wall';
PARA b:=99 PARAMENOS 1 FACA
GRAVELN(b, a, c, ', '+chr(13)+chr(10), b, a, '.'+
chr(13)+chr(10)+'Take one down, pass it around,'+
chr(13)+chr(10),(b-1),a,c,'.'+chr(13)+chr(10))
FIM.
// PasScript version of 99 Bottles of beer (Bottles.pas)
// See http://users.ints.net/virtlabor/passcript/
// Philipp Winterberg, http://www.winterbergs.de
program Bottles;
var
WordApp, Range: variant;
b: integer;
Strophe: string;
begin
CoInitialize;
try
WordApp:= CreateOleObject('Word.Application');
WordApp.Visible:= true;
WordApp.Documents.Add;
Range:= WordApp.Documents.Item(1).Range;
for b:=99 downto 1 do
begin
Strophe:= inttostr(b) + ' bottle(s) of beer on the wall,' +#13#10+
inttostr(b) + ' bottle(s) of beer.' +#13#10+
'Take one down, pass it around,' +#13#10+
inttostr(b-1) + ' bottle(s) of beer on the wall.' +#13#10;
Range.Text:= Range.Text + Strophe
end
finally
CoUninitialize
end
end.
#!/usr/bin/perl -w
use Math::String 1.16;
use Math::BigInt 1.48;
my $i = Math::String->new('99',['0'..'9']); # counter
my $cs = ["a".."z","A".."Z"," ",",","(",")","\n"]; # charset
my $c = 'Math::String'; # class
my $u = $c->from_number( # b. of beer on wall
"143457256751672444408485136195337476997885002593618110354",$cs);
my $v = $c->from_number( # take one, pass it
"2183742159727155773060245326632596445683097582725669500",$cs);
my $w = $c->from_number( # bottles of beer
"121961920301233380909600391518980493",$cs);
while ($i ne '00') { print "$i$u$i$w$v"; $i--; print "$i$u\n"; }
#!/usr/bin/perl
# Marty Pauley sings "99 bottles of beer"
use Lingua::EN::Inflect 'inflect';
print inflect(<<"SING") for (reverse(1 .. 99));
NO(bottle,$_) of beer on the wall,
NO(bottle,$_) of beer,
Take one down and pass it around,
NO(bottle,@{[$_-1]}) of beer on the wall.
SING
By Dave Rolsky (140 Bytes)
$b=sub{(99_-@_-$_||No)." bottles of beer on the wall\n"};
warn map{&$b.substr(&$b,0,18)."\nTake one down, pass it around\n".&$b(0).$/}0..98
' "99 Bottles of Beer on the Wall" QBasic / Perl Polyglot '.
' Copyright (C) 2000 Jeff Connelly <polyglotqbperl@xyzzy.cjb.net> '.
' May be freely distributed '.
' '.
' Probably only works in DOS. You can get QBasic 1.1 with DOS, or '.
' on the World Wide Web at http://www.neozones.com/ . '.
' Note that QBasic reformats source code as it is opened; so do not '.
' save this file inside QBasic if you want it to be parsed by Perl. ';
'';sub function{}sub st{}
function st$(x1, y!, m$)
st$ = ltrim$(str$(y!))
end function
'!;
m%=99'%;$STATIC=9x2;
do
'NUL'; do {
print st$(x1,m%-0%,z.$); '',print"\cH"x3;print
'',$STATIC;
print " bottles of beer on the wall";
print ''; print "\n"x2; <<;
print
print st$(x1,m%-0%,z.$); '',print"\cH"x3;print
'',$STATIC;
print " bottles of beer on the wall,";
print ''; print "\n";
print st$(x1,m%-0%,z.$); '',print"\cH"x3;print
'',$STATIC;
print " bottles of beer,";
print '' and print "\n";
print "Take one down, pass it around,";
print ""; ''; print "\n";
''; <<;
print
''; --$STATIC;
m%=m%-1+foo.
''} until $STATIC == 0 or !<<;;
loop until m%=0'%-1
system
PH/FI is a light, and powerful, interpreter for server-parsed
("dynamic" this year, SSH since NCSA invented the thing ages ago)
html which can be used either as a CGI redirected processor or
embbedded in Apache servers. Its web site is
<a HREF="http://php.iquest.net/">http://php.iquest.net/</a>.
<HTML>
<HEAD>
<TITLE>
99 Bottles of beer.
</TITLE>
<META NAME="Author" CONTENT="Alejandro López-Valencia">
<META NAME="E-Mail" CONTENT="palopez@usa.net">
<META NAME="Description" CONTENT="Written in PHP/FI 2.0">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?
/* Don't show the access information footer */
setshowinfo(0)
>
<?
/* Drink with the boys... */
$hic = 99;
while ($hic > 0) (
$huc = $hic - 1;
/* Waste CPU, but you are using a Cray, aren't you? */
if ($hic = 1) (
$huc = $hic;
) ;
if ($hic = 1) $bottles = "bottle" else $bottles = "bottles" ;
echo $hic $bottles of beer on the wall, $hic $bottles of beer. <BR> ;
echo Take one and pass it around, <BR> ;
echo "$huc $bottles of beer on the wall. <BR>" ;
$hic--;
)
/* Pass out */
echo No more bottles of beer on the wall. <BR> ;
echo No more bottles of beer... <BR> ;
echo Go to the store and buy some more... <BR> ;
echo 99 bottles of beer. <BR> ;
?>
</BODY>
</HTML>
By Samuel Dennler for PHP4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>99 Bottle of beer</title>
<meta name="author" content="Samuel Dennler">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1>99 Bottle of beer</h1>
<?php
for($i=99; $i>=1; $i--){
$s = $i > 1?"s":"";
echo "<p>$i Bottle$s of beer on the wall, $i bottle$s of beer.<br>";
echo "Take one down and pass it around,<br>";
echo ($i-1)." bottle$s of beer on the wall.</p>\n";
}
?>
<p>No more bottles of beer on the wall.<br>
No more bottles of beer...<br>
<a href="<?php echo $PHP_SELF ?>">Go to the store</a> and buy some more...<br>
99 bottles of beer.</p>
</body>
</html>
PQ
C 99 bottles of beer (Boy do I have a thirst!)
C Author: Trog Woolley 20/Mar/02
RI
RO
+99
1 D+
O bottles of beer on the wall, +
D+
O bottles of beer on the wall.
OTake one down, pass it a round, +
-1
D+
O bottles of beer on the wall.
O
IF A >00 G 1
ONo more beer.
X
#!/usr/local/bin/pike
// A simple version made in Pike (http://pike.roxen.com/)
// Author: Ivan Voras <ivoras@fer.hr>
int main() {
int i = 99;
while (i > 0) {
if (i > 1)
write (i+" bottles of beer on the wall, "+i+" bottles of beer,\n");
else
write ("one bottle of beer on the wall, one bottle of beer,\n");
write ("take one down, pass it around,\n");
i--;
switch (i) {
case 0:
write ("no more bottles of beer on the wall.\n");
break;
case 1:
write ("one bottle of beer on the wall.\n");
break;
default:
write (i+" bottles of beer on the wall.\n");
break;
}
}
return 0;
}
PIL is the scripting language for the Pirch IRC client. Pirch's website
is supposed to be located at http://www.pirchat.com/ , but I haven't been
able to connect to it in a while. Seems like the program is no longer
maintained. You can probably find information about it at
http://www.pirch.com/ .
{
99bb.pil by evil_deceiver
[ http://justice.loyola.edu/~mcoffey/ ]
function: sings "99 Bottles of Beer", starting at a
user-specified number of bottles, to the channel whose
window is active.
bugs: won't do much of anything if the active window is a
server window.
warnings: most networks will disconnect you for flooding like
this. make sure your outgoing flood control is set high.
to run: load PIL (in Aliases) as "[99bb]", then type
"/runscript [99bb]" followed by the number of bottles you
want to start with.
}
btlcount:=$1;
command('/me sings... o/`');
command(btlcount,' bottles of beer on the wall');
command(btlcount,' bottles of beer');
command('Take one down, pass it around');
while btlcount>2 do begin
btlcount:=btlcount-1;
command(btlcount,' bottles of beer on the wall!');
command('o/` ~~ o/` ~~ o/` ~~ o/` ~~ o/`');
command(btlcount,' bottles of beer on the wall');
command(btlcount,' bottles of beer');
command('Take one down, pass it around');
end;
btlcount:=btlcount-1;
command(btlcount,' bottle of beer on the wall!');
command('o/` ~~ o/` ~~ o/` ~~ o/` ~~ o/`');
command(btlcount,' bottle of beer on the wall');
command(btlcount,' bottle of beer');
command('Take one down, pass it around');
command('You',char(39),'ve finally drunk all the beer on the wall!');
command('/me takes a bow.');
R: PILOT version of 99 Bottles of Beer
: hacked by Akira KIDA, <SDI00379@niftyserve.or.jp>
C:BOTTLES=99
U:*BEERS
*LOOP
T:$T of beer on the wall, $T.
T:Take one down, pass it around.
C:BOTTLES=BOTTLES-1
U:*BEERS
T:$T on the wall.
T:
J(BOTTLES>0):*LOOP
E:
*BEERS
C(BOTTLES=0):$T=No more bottles
C(BOTTLES=1):$T=1 bottle
C(BOTTLES>1):$T=#BOTTLES bottles
E:
This is written in the PiXCEL programming language
available from www.vysor.com
{Pixcl version of 99 bottles of beer}
Initialize:
SetColorPalette(GENERATE)
WinGetActive(Win$)
UseCoordinates(PIXEL)
UseBackGround(OPAQUE,192,192,192)
DrawBackGround
WinLocate(Win$,100,100,520,360,Res)
Title$ = "100 Bottles"
WinTitle(Win$, Title$)
Start:
x = 100
Str(x,x$)
while x <> 1
DrawText(20,90,"Bottles of beer on the wall, bottles of beer ")
Drawtext(192,90,x$)
Drawtext(20,120,"Take one down and pass it around,")
x = x -1
Str(x,x$)
Drawtext(20,150,x$)
Drawtext(40,150,"Bottles of beer on the wall")
Waitinput(100)
Drawtext(387,90," ")
endwhile
Waitinput()
Regards Mike Phillips
/* And here is the PL/I version: */
BOTTLES: PROC OPTIONS(MAIN);
DCL NUM_BOT FIXED DEC(3);
DCL PHRASE1 CHAR(100) VAR;
DCL PHRASE2 CHAR(100) VAR;
DCL PHRASE3 CHAR(100) VAR;
DO NUM_BOT = 100 TO 1 BY -1;
PHRASE1 = NUM_BOT||' Bottles of Beer on the wall,';
PHRASE2 = NUM_BOT||' Bottles of Beer';
PHRASE3 = 'Take one down and pass it around';
DISPLAY(PHRASE1||PHRASE2);
DISPLAY(PHRASE3);
END;
PHRASE1 = 'No more Bottles of Beer on the wall, ';
PHRASE2 = 'No more Bottles of Beer';
PHRASE3 = 'Go to the store and buy some more';
DISPLAY(PHRASE1||PHRASE2);
DISPLAY(PHRASE3);
END BOTTLES;
PL/SQL is a programming language that resides in an Oracle database.
As PL/SQL has no standard input or output this version is written
to be run from the SQLPlus command line using an anonymous PL/SQL block.
/* Start of code */
set serveroutput on
DECLARE
counter NUMBER;
BEGIN
dbms_output.enable;
FOR counter IN REVERSE 1..99 LOOP
dbms_output.put_line(counter || ' bottles of beer on the wall,');
dbms_output.put_line(counter || ' bottles of beer.');
dbms_output.put_line('Take one down, pass it around,');
IF (counter != 1) THEN
dbms_output.put_line(counter - 1 || ' bottles of beer on the wall.');
ELSE
dbms_output.put_line('No more beers.');
END IF;
END LOOP;
END;
/
/* End of code (The "/" in the line above is very important) */
! The main program "99 bottles ..." programmed in PLEX !
! Programmer Staale Andersen etosta@eto.ericsson.se !
! Comment: The need for an own parameterlist and a signal survey, !
! leads to the whole beer program beeing in 3 parts. !
DOCUMENT BEERPROGRAM;
DECLARE;
GLOBAL NSYMB COCA99 (#FFFF);
GLOBAL STRING BEERS (7);
STRING VARIABLE ONWALL1 31 DS;
STRING VARIABLE ONWALL2 63 DS;
STRING VARIABLE BOTTLES 31 DS;
STRING VARIABLE TAKEDOWN 63 DS;
VARIABLE CBEER 16 DS;
VARIABLE CIOID 16 DS;
VARIABLE TIOID 16;
VARIABLE TSTARTPHASE 16;
VARIABLE TSIGNALKEY 16;
VARIABLE TBLOCKINFO 16;
END DECLARE;
PROGRAM BEERPROGRAM;
PLEX;
ENTER STTOR WITH
+,
TSTARTPHASE,
+,
+,
+,
+,
TSIGNALKEY;
TBLOCKINFO = #100;
SEND STTORRY WITH
TSIGNALKEY,
TBLOCKINFO,
5,
255;
EXIT;
COMMAND BEERS TYPE COCA99,
ID IS TIOID;
CIOID = TIOID;
ONWALL1 = " BOTTLES OF BEER ON A WALL, ";
ONWALL2 = " BOTTLES OF BEER ON A WALL.";
BOTTLES = " BOTTLES OF BEER";
TAKEDOWN = "TAKE ONE DOWN AND PASS IT AROUND, ";
ON CBEER FROM 99 DOWNTO 1 DO
CASE CBEER IS
WHEN 1 DO
BOTTLES = " BOTTLE OF BEER";
ONWALL1 = " BOTTLE OF BEER ON A WALL, ";
ONWALL2 = "NO MORE BOTTLES OF BEER ON A WALL.";
WHEN 2 DO
ONWALL2 = " BOTTLE OF BEER ON A WALL.";
OTHERWISE DO;
ESAC;
INSERT VALUE CBEER, ID IS CIOID,
FORMAT IS 5;
INSERT STRING ONWALL1, ID IS CIOID;
INSERT VALUE CBEER, ID IS CIOID,
FORMAT IS 5;
INSERT STRING BOTTLES, ID IS CIOID;
WRITE AFTER 1 NL, ID IS CIOID,
ABRANCH IS ERROR;
INSERT STRING TAKEDOWN, ID IS CIOID;
IF CBEER /= 1 THEN
INSERT VALUE (CBEER-1), ID IS CIOID,
FORMAT IS 5;
FI;
INSERT STRING ONWALL2, ID IS CIOID;
WRITE AFTER 1 NL, ID IS CIOID,
ABRANCH IS ERROR;
NO;
ERROR)
RELEASE DEVICE, ID IS CIOID,
ABRANCH IS EXIT;
EXIT)
EXIT;
END PROGRAM;
DATA;
END DATA;
*END;
ID BEERPROGRAM TYPE DOCUMENT;
CLA 19055;
NUM CAA 100 99;
REV A;
DAT 96-12-12;
DES ETO/TX/M/N STA;
RES ETO/TX/M/N STA;
APP ETO/TX/M/N TV;
END ID;
! The source parameter list !
DOCUMENT BEERSPARAM;
BLOCK BEER;
TYPE BTBEER;
TYPEEXT BTEXTBEER;
USE BEERPROGRAM;
NSYMB BTBEER = #8000;
NSYMB BTEXTBEER= #4000;
STRING BEERS = "BEERS";
NSYMB COCA99 = #0;
END BLOCK;
*END;
ID BEERSPARAM TYPE DOCUMENT;
CLA 19073;
NUM CAA 100 99;
REV A;
DAT 96-12-13;
DES ETO/TX/M/N STA;
RES ETO/TX/M/N STA;
APP ETO/TX/M/N TV;
END ID;
! Signal Survey !
DOCUMENT BEERSURVEY;
SIGNALSURVEY;
USE BLOCK BEER;
STTOR , R , 723/15514 - APZ210 ;
STTORRY , S , 724/15514 - APZ210 ;
END SIGNALSURVEY;
*END;
ID BEERSURVEY TYPE DOCUMENT;
CLA 15514;
NUM CAA 100 99;
REV A;
DAT 96-12-13;
DES ETO/TX/M/N STA;
RES ETO/TX/M/N STA;
APP ETO/ETOTX/M/N TV;
END ID;
//99-Bottles-of-beer
//Made by John Eriksson 2003
//Compile with PocketC for PalmOS
//http://www.orbworks.com
#define memo "99-Bottles-of-beer"
char n='n';
getnbr(int i){
string s;
switch(i){
case 0:
s=n+"o more bottles";
if(n=='n') n='N';
else n='n';
break;
case 1:
s="1 bottle";
break;
default:
s=i+" bottles";
break;
}
return(s);
}
main(){
int b=99,m,x=1;
if((m=mmfind(memo))>0)
mmdelete();
m=mmnew();
mmputs(memo+"\n\n");
clear();
puts("Please wait...\n");
while(x){
mmputs(getnbr(b)+" of beer on the wall, "+getnbr(b)+" of beer.\n");
b--;
if(b<0){
b=99;
x=0;
mmputs("Go to the store, buy some more, ");
}
else
mmputs("Take one down, pass it around, ");
mmputs(getnbr(b)+" of beer on the wall.\n");
}
puts("Done!\n");
mmclose();
alert("Song is stored in the memo named '"+memo+"'");
}
define beer(n);
define :inline PLURAL(N);
(N==1 and nullstring or "s")
enddefine;
lvars i;
for i from n by -1 to 1 do;
nl(1);
nprintf(PLURAL(i), i, '%P bottle%P of beer on the wall.');
nprintf(PLURAL(i), i, '%P bottle%P of beer!');
nprintf(i==1 and "it" or "one", 'Take %P down, pass it around.');
if i>1 then
nprintf(PLURAL(i-1), i-1, '%P more bottle%S of beer on the wall.');
else
npr('No more bottles of beer on the wall.');
endif;
endfor;
enddefine;
beer(100);
{ Portable ISO Standard Pascal version of 99 Bottles of beer (Bottles.pas) }
{ See http://www.programmersheaven.com/zone24/cat351/4262.htm }
{ Philipp Winterberg, http://www.winterbergs.de }
program Bottles(output); var b: integer; {$c+,t+}
begin
for b:= 99 downto 1 do
writeln(b, ' bottle(s) of beer on the wall,', #13#10,
b, ' bottle(s) of beer.', #13#10,
'Take one down, pass it around,', #13#10,
(b-1), ' bottle(s) of beer on the wall.', #13#10)
end.
Posix is yet another U**x shell.
#!/bin/sh
# POSIX shell version of 99 Bottles
# Dave Plonka - plonka@carroll1.cc.edu
typeset -i n=99
typeset bottles=bottles
typeset no
while let n
do
echo "${n?} ${bottles?} of beer on the wall,"
echo "${n?} ${bottles?} of beer,"
echo "take one down, pass it around,"
n=n-1
case ${n?} in
0)
no=no
bottles=${bottles%s}s
;;
1)
bottles=${bottles%s}
;;
esac
echo "${no:-${n}} ${bottles?} of beer on the wall."
echo
done
exit
-- PostgreSQL Version of "99 Bottles of Beer".
-- by David Eddyshaw, david@jeddyshaw.freeserve.co.uk
-- Uncomment the C-style comments if the database
-- you're using doesn't include PL/pgSQL: it's
-- wanted for the shelf-stacking function fill().
-- See http://www.postgresql.org/
\set QUIET
\pset format unaligned
/*
create function plpgsql_call_handler()
returns opaque
as '/usr/lib/pgsql/plpgsql.so' -- path depends on your setup
language 'C';
create trusted procedural language 'plpgsql'
handler plpgsql_call_handler
lancompiler 'PL/pgSQL';
*/
create table Bottles (rownum integer);
create function fill()
returns text
as 'begin
for i in 1 .. 100 loop
insert into Bottles values (i);
end loop;
return ''Filled the shelf.'';
end;'
language 'plpgsql';
select fill();
create function bob(integer)
returns text
as 'select
case when $1 = 1 then ''1 bottle of beer''
when $1 = 0 then ''No more bottles of beer''
else $1 || '' bottles of beer''
end
as result'
language 'sql';
\pset title '\n99 Bottles of Beer.\n'
select bob(100-rownum)||' on the wall,\n'||
bob(100-rownum)||';\nTake one down and pass it around:\n'||
bob(99-rownum) ||' on the wall.\n'
as sing
from Bottles
where rownum < 100;
-- Be tidy: clean up
/*
drop procedural language 'plpgsql';
drop function plpgsql_call_handler();
*/
drop function bob(integer);
drop function fill();
drop table Bottles;
% How to do 99 Bottles of Beer in Postscript.
% This doesn't go out to the printer. You'd need to hook a serial port
% to your LaserPrinter or Postscript typesetter
/beer {
/bottles 7 string def
99 -1 1
{ dup bottles cvs print ( bottles of beer on the wall, )
bottles print (bottles of beer. Take one down, pass it around, )
1 sub bottles cvs print ( bottles of beer on the wall. )
} for
(No more bottles of beer on the wall, no more bottles of beer. )
(Go to the store and buy some more... 99 bottles of beer) } def
%!PS
% The 99 bottles of beer song in PostScript. This file
% can be sent to a PostScript printer (it'll be about
% eight pages or so...)
% Stuart Morris
% ------------- Variables & Procedures ------------
/LM 72 def % left margin
/ypos 720 def % initial top position
/BM 72 def % bottom margin
/lineheight 18 def % height of a line of text
% starts a new line
/crlf
{
ypos lineheight sub
/ypos exch def
LM ypos moveto
} def
% starts a new page if current one is full
/newpage?
{
ypos BM lt
{
showpage
/ypos 720 def
LM ypos moveto
} if
} def
% returns the correct syntax of the bottle
% string ("bottle" if one, "bottles" otherwise)
/bottlestring % stack: number of bottles
{
1 eq
{
( bottle of beer)
}
{
( bottles of beer)
} ifelse
} def
% ------------- Main Program ----------------
LM ypos moveto
/Times-Roman findfont
lineheight 2 sub scalefont
setfont
99 -1 1
{
/numbottles 2 string def
dup numbottles cvs show
dup bottlestring show ( on the wall, ) show
numbottles show dup bottlestring show (,) show
crlf
(Take one down, pass it around, ) show
1 sub dup numbottles cvs show
bottlestring show ( on the wall.) show
crlf crlf
newpage?
} for
showpage
' FirstBasic/PowerBasic version of 99 Bottles of beer (Bottles.bas)
' See http://www.powerbasic.com/
' Philipp Winterberg, http://www.winterbergs.de
KEY OFF : COLOR 7, 0 : CLS
FOR b% = 99 TO 1 STEP -1
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."
PRINT " "
NEXT b%
END
$PBExportHeader$f_99_bottlesofbeer.srf
global type f_99_bottlesOfBeer from function_object
end type
forward prototypes
global function integer f_99_bottlesofbeer ()
end prototypes
global function integer f_99_bottlesofbeer ();//PowerScript Version
//99 Bottles of Beer on the Wall
//PowerScript 8.x in PowerBuilder 8.x by Sybase
//www.sybase.com
//Written by:
// Nathan Pralle http://tarsi.binhost.com
// Ryan Grummer rgrummer@frontiernet.net
long ll_numBottles=99
string ls_message
do while(ll_numBottles>0)
ls_message=string(ll_numBottles)+" bottle(s) of beer on the wall.~r~n"
ls_message=ls_message+string(ll_numBottles)+" bottle(s) of beer.~r~n"
ls_message=ls_message+"Take one down, pass it around.~r~n"
ls_message=ls_message+string(ll_numBottles - 1)+" bottle(s) of
beer on the wall."
MessageBox("99 Bottles of Beer",ls_message)
ll_numBottles=ll_numBottles - 1
loop
return 1
end function
' PC Board Programming Language (PPL) Version of 99 Bottles of beer
integer i
for i=100 to 1 step -1
println i," Bottle(s) of beer on the wall, ",i," bottle(s) of beer"
println "Take one down and pass it around,"
println i-1," bottle(s) of beer on the wall"
next
end
'compile with pplc (PCBoard Programming Language Compiler) delivered
'with PC Board
'PC Board is Copyright (C) 1993-95, Clark Development Company, Inc.
# "99 Bottles of Beer" for Procmail -- body filtering version
# era Fri Jun 12 18:59:44 1998 http://www.iki.fi/~era/99bottles/
# Reacts on incoming mail -- if the Subject: matches the regex, start looping
# This will create a large amount of mail in your inbox. You have been warned
SHELL=/bin/sh
# Might need to change PATH e.g. if it doesn't normally include the location
# where you have formail installed
#PATH=$PATH:/usr/local/contrib/bin
# If the incoming message matches this regex, generate a copy with a
# new subject line, one bottle less, and send it, too, to myself.
# Also change the body to reflect the new number.
# (Other than that, this is basically the same as the looprc version)
:0c
* ^Subject:\/\<*[1-9][0-9]*\<+bottles?\<+of\<+beer\>*$
{
# Store MATCH before processing it more
SUBJECT="$MATCH"
# Extract string part
:0
* SUBJECT ?? bottles?\/\<.*
{ STRINGPART="$MATCH" }
# Extract number part and resend the message
:0
* SUBJECT ?? ^^\<*\/[0-9]+
* $ $MATCH^0
* -1^0
{
# Gack, hafta put score in a "real" variable to make it useful
BOTTLES=$=
# Ugliness: Precalculate the number of "one down" bottles
# for the last stanza of the song
:0
* $ $BOTTLES^0
* -1^0
{ }
NEWBOTTLES=$=
:0
* NEWBOTTLES ?? ^^0^^
{ NEWBOTTLES="No" }
# Calculate whether we need to leave out the plural s anywhere
S="s" NEWS="s"
:0
* BOTTLES ?? ^^1^^
{ S="" }
:0
* NEWBOTTLES ?? ^^1^^
{ NEWS="" }
:0bfw # Filter the body using sed
| sed -e "s/$BOTTLES[ ]*bottles*/$NEWBOTTLES bottle$NEWS/g" \
-e "s/$MATCH[ ]*bottles*/$BOTTLES bottle$S/g"
# Okay, body filtering done. Now proceed as before:
# Resend the message with a new Subject: to myself
:0
| formail -I "Subject: $BOTTLES bottle$S$STRINGPART" | \
$SENDMAIL $SENDMAILFLAGS $LOGNAME
}
# Still here? That means there are no more bottles.
:0
| formail -I "Subject: No bottles$STRINGPART" | \
$SENDMAIL $SENDMAILFLAGS $LOGNAME
}
# # You might want to uncomment this recipe to put the @&$0fF!!
# # bottles of beer messages in their own mailbox
# :0:
# * ^Subject:\<*([1-9][0-9]|No)*\<+bottles?\<+of\<+beer\>*$
# ./beer
# To test this, INCLUDERC= this file from your regular .procmailrc
# (assuming you have one set up; check the manual pages if not)
# and send yourself a message with a subject line with the required
# number of bottles. A test message is in test.msg in this directory.
#
# unix$ /usr/lib/sendmail $LOGNAME <test.msg
#
# or for testing purposes even just
#
# unix$ procmail ./bodyfilter < test.msg
#
# or even
#
# unix$ procmail VERBOSE=yes DEFAULT=./oops ./bodyfilter <test.msg
#
'--------------------------------------------------------------------
'SOURCE CODE TITLE: 99 Bottles of beer on the wall
'--------------------------------------------------------------------
'AUTHOR NAME: Rohit Vishal Kumar
'--------------------------------------------------------------------
'WEB ADDRESS: http://www.angelfire.com/nb/neeraja-rohit/
'--------------------------------------------------------------------
'EMAIL ADDRESS: rohitvk"AT"lycos"DOT"com
'--------------------------------------------------------------------
'SOURCE DATED: 26 January 2002
'--------------------------------------------------------------------
'SOURCE STATUS: Public Domain
'--------------------------------------------------------------------
'DESCRIPTION: This source code was developed as my first
' learning attempt at ProFan 3.3.
' Use it to learn ProFan 3.3.
' You might start liking the language :-)
'--------------------------------------------------------------------
'REQUIREMENTS: Nothing Specific
'--------------------------------------------------------------------
'CREDITS: Developers of Profan - It certainly makes prog-
' ramming a lot of fun
'--------------------------------------------------------------------
' Defining the counter to be used in the Program
DECLARE X%, Y%
' Creating the window
WINDOW 20,20 - 400,400
' Assigning the Title of the Windows
WINDOWTITLE "99 Bottles of Beer on the Wall"
' Printing the Welcome Message on the Screen
PRINT "Welcome to 99 Bottles of Beer..."
PRINT
PRINT "Programmed By - "
PRINT "Rohit Vishal Kumar"
PRINT "Flat No: B-21/11"
PRINT "E.C.T.P. Phase - IV, Type - B"
PRINT "Calcutta - India"
PRINT "Pin : 700 107"
PRINT "Phone : (91-33) 443-5858"
PRINT "Email: rohitvkAThotmailDOTcom"
PRINT
PRINT "Please Press Any Key to Run the Program..."
'Wait for the User to Press Any Key
WAITKEY
' Initialize the variables to be used
LET X% = 1
LET Y% = 99
' Use the While Loop - While X is less than 101
' Note: 101 is used to make the counter go down to zero and print
' going to store message
WHILE @LT(X%, 101)
' Write the Lyrics
PRINT Y%," bottles of beer on the wall"
PRINT Y%," bottles of beer..."
PRINT "Take one down and pass it around..."
' Subtract X from 100
LET Y%=@SUB(100,X%)
' The IF Loop - 1. If Y = 1 then say bottle instead of bottles
' The IF Loop - 2. If Y = 0 then go to the store
' The IF Loop - 3. ELSE Print the message
IF @EQU(Y%,1)
PRINT Y%," beer bottle on the wall."
ELSEIF @EQU(Y%,0)
PRINT
PRINT "Now there are none....."
PRINT "I need some more ......."
PRINT "I am going to the store ... hic :-)"
ELSE
PRINT Y%," beer bottles on the wall."
ENDIF
PRINT
'Increment X by One
LET X%=@ADD(X%,1)
WEND
'Wait for a key press from the user
WAITKEY
'Show the message box with Okay Button
MESSAGEBOX "Thank you very much for Drinking Along with Me...",\
"Shoot...Hic...Shut Program",64
'Finally End the Program
END
<a href=http://www.progress.com>Progress</a> is a database system
that is used to create enterprise database solutions.
/* Progress 4GL version of 99 Bottles of Beer.
* programmer: Rich Uchytil rich@cray.com
* 10/30/95
*/
def var i as int no-undo format "z9".
do i = 99 to 1 by -1:
disp i "bottles of beer on the wall," skip
i @ x as int format "z9" "bottles of beer" skip
"Take one down and pass it around," skip
i - 1 format "z9" "bottles of beer on the wall."
with no-labels no-box no-attr 1 down.
pause 1 no-message. /* needed otherwise it would run too fast */
end.
% 99 bottles of beer.
% Remko Troncon <spike@kotnet.org>
bottles :-
bottles(99).
bottles(1) :-
write('1 bottle of beer on the wall, 1 bottle of beer,'), nl,
write('Take one down, and pass it around,'), nl,
write('Now they are alle gone.'), nl.
bottles(X) :-
X > 1,
write(X), write(' bottles of beer on the wall,'), nl,
write(X), write(' bottles of beer,'), nl,
write('Take one down and pass it around,'), nl,
NX is X - 1,
write(NX), write(' bottles of beer on the wall.'), nl, nl,
bottles(NX).
0010 ! ProvideX version of 99 Bottles of beer (Bottles.bbx)
0015 ! See http://www.pvx.com/down_pages/providex/windows/home.html
0020 ! Philipp Winterberg, http://www.winterbergs.de
0030
0040 CLEAR
0042 FOR b=99 TO 1 STEP -1
0050 ? b," bottle(s) of beer on the wall,"
0060 ? b," bottle(s) of beer."
0070 ? "Take one down, pass it around,"
0080 ? b-1," bottle(s) of beer on the wall."+$0A$+$0D$
0090 NEXT
0099 STOP
; PureBasic version of 99 Bottles of beer (Bottles.pb)
; See http://www.purebasic.com/
; Philipp Winterberg, http://www.winterbergs.de
OpenConsole():ConsoleColor(0,15):a$=" bottle(s) of beer"
ConsoleTitle("99"+a$):c$ = " on the wall":ClearConsole()
For b = 99 To 1 Step -1
PrintN(" "+Str(b)+a$+c$+","):PrintN(" "+Str(b)+a$+".")
PrintN(" Take one down, pass it around,")
PrintN(Chr(32)+Str(b-1)+a$+c$+Chr(46)):PrintN(Chr(32))
Next b
Input():End
PV-Wave, also known as IDL, is a language designed for visual data analysis.
;
; 99 bottles of beer
; V1
; Author: George M.Sigut (sigut@bs.id.ethz.ch)
;
; yes, I DO know the second loop could be unrolled
;
ninety_nine = 99
texta = ' bottles of beer'
textb = ' bottle of beer'
textf = ' no more'
;
number1 = strcompress(string(ninety_nine))
text1 = texta
number2 = strcompress(string(ninety_nine-1))
text2 = texta
for i=ninety_nine,3,-1 do begin &$
print,number1,text1,' on the wall' &$
print,number1,text1 &$
print,' you take one down & pass it around' &$
print,number2,text2 &$
print &$
number1 = number2 &$
number2 = strcompress(string(i-2)) &$
endfor
;
text1 = texta
text2 = textb
for i=2,1,-1 do begin &$
print,number1,text1,' on the wall' &$
print,number1,text1 &$
print,' you take one down & pass it around' &$
print,number2,text2 &$
print &$
number1 = number2 &$
text1 = textb &$
number2 = textf &$
text2 = texta &$
endfor
;
-- Py version of 99 Bottles of beer (Bottles.py)
-- See http://www.lanset.com/dcuny/py.htm
-- Philipp Winterberg, http://www.winterbergs.de
var a = " bottle(s) of beer", c = " on the wall"
var d = "Take one down, pass it around,"
for b = 99 to 1 by -1 do
printf("%d%s%s,\n%d%s.\n%s\n%d%s%s.\n\n", b, a, c, b, a, d, (b - 1), a, c)
end for
By Oliver Xymoron (133 Bytes)
a,t="\n%s bottles of beer on the wall","\nTake one down, pass it around"
for d in range(99,0,-1):print(a%d*2)[:-12]+t+a%(d-1 or'No')
#!/usr/local/bin/python
# python version of 99 bottles of beer, compact edition
# by Fredrik Lundh (fredrik_lundh@ivab.se)
def bottle(n):
try:
return { 0: "no more bottles",
1: "1 bottle"} [n] + " of beer"
except KeyError: return "%d bottles of beer" % n
for i in range(99, 0, -1):
b1, b0 = bottle(i), bottle(i-1)
print "%(b1)s on the wall, %(b1)s,\n"\
"take one down, pass it around,\n"\
"%(b0)s on the wall." % locals()