Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Apple Script

Date:04/20/05
Author:Kristopher Johnson
URL:n/a
Comments:3
Info:n/a
Score: (3.01 in 139 votes)
-- AppleScript version of "99 Bottles of Beer"
-- by Kristopher Johnson  kdj@mindspring.com

to createBottleString for aNumberOfBottles
    if aNumberOfBottles is 0 then
        return "No more bottles"
    else if aNumberOfBottles is 1 then
        return "1 more bottle"
    else
        return (aNumberOfBottles as string) & " bottles"
    end if
end createBottleString

set lyrics to ""
repeat with numberOfBottles from 99 to 1 by -1
    set bottleString to (createBottleString for numberOfBottles)
    set lyrics to lyrics & bottleString & " of beer on the wall, " & bottleString & " of beer.  " &
return
    set lyrics to lyrics & "Take one down and pass it around, " & return
    set lyrics to lyrics & (createBottleString for (numberOfBottles - 1)) & " of beer on the wall. 
" & return
end repeat
set lyrics to lyrics & "No more bottles of beer on the wall, no more bottles of beer." & return
set lyrics to lyrics & "Go to the store and buy some more." & return
set lyrics to lyrics & "99 bottles of beer on the wall."
return lyrics

Download Source | Write Comment

Alternative Versions

Comments

>>  z said on 05/05/08 03:27:26

z

>>  Adrien Bertrand said on 12/26/08 05:10:46

Adrien Bertrand Nice !

>>  Youri H said on 06/06/10 12:46:42

Youri H perhaps u could use the "say" command :P

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: