99 bottles of beer on the wall

Jeanne A. E. DeVoto jeanne at runrev.com
Sat Jul 27 20:24:01 EDT 2002


At 8:58 PM -0700 7/26/2002, Kee Nethery wrote:
>Just thought I'd mention that there is no example code for Revolution
>singing 99 bottles of beer on the wall and of the 300+ languages
>represented. <http://99-bottles-of-beer.ls-la.net/r.html>

A shame and a disgrace. ;-)

I did one last night. It's similar to David's but I believe the generated
lyrics in this one are correct - David, you might want to adapt those
changes....


constant startBottles = 99
local bottlesLeft = 99
local currentVerseMessage

on mouseUp
  if currentVerseMessage is empty then
    displayBottleVerse -- start the song
  else -- song is already playing, so stop it
    cancel currentVerseMessage
    put empty into currentVerseMessage
    put empty
  end if
end mouseUp

on displayBottleVerse
  -- sing a verse, using the bottlePhrase function
  -- and set up the variable for the next verse
  switch bottlesLeft
  case zero
    put bottlePhrase(bottlesLeft) && "on the wall," \
        && toLower(bottlePhrase(bottlesLeft)) & return \
        & "Go to the store and buy some more," \
        && toLower(bottlePhrase(startBottles))
    put startBottles into bottlesLeft
    break
  default
    put bottlePhrase(bottlesLeft) && "on the wall," \
        && toLower(bottlePhrase(bottlesLeft)) & return \
        & "Take one down and pass it around," \
        && toLower(bottlePhrase(bottlesLeft - 1))
    subtract 1 from bottlesLeft
  end switch
  send displayBottleVerse to me in 1 second
  put the result into currentVerseMessage
end displayBottleVerse

function bottlePhrase theNumber
  -- generate the "base phrase" used to make a verse
  switch theNumber
  case zero
    return "No more bottles of beer"
    break
  case one
    return "One last bottle of beer"
    break
  default
    return theNumber && "bottles of beer"
  end switch
end bottlePhrase

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - The Solution for Software Development
http://www.runrev.com/





More information about the use-livecode mailing list