RosettaCode

Geoff Canyon gcanyon at gmail.com
Mon Jul 8 01:20:01 EDT 2013


Thanks for contributing!

Hopefully I don't come off quite that harsh... In any case, there doesn't
seem to be a better way to add a new entry than:

1. Go to the page for 99 bottles.
2. Click the entry for the language before LiveCode alphabetically --
Liberty BASIC in this case.
3. Edit that entry.
4. Insert the following at the bottom, after a couple CRs:

=={{header|LiveCode}}==
<lang livecode>function beerMe numberOfBottles
      put "XX bottles of beer on the wall" into verseA
      put "Take one down, pass it around" into verseB
      repeat with N = numberOfBottles down to 1
            put replaceText(verseA,"XX",N) & cr & word 1 to 4 of \
            replaceText(verseA,"XX",N) & cr & verseB & cr &
replaceText(verseA,"XX",N-1) \
            & cr & cr after theSong
      end repeat
      return theSong
end beerMe</lang>

I generally add a comment that I'm adding LiveCode, and then save. It could
also be done by editing the entry *after* LiveCard alphabetically, and
putting the LiveCode entry before that entry, with a couple CRs between
them. Or by editing the whole page, but that would be harder because you'd
have to search through the markdown to find the right place to put LiveCode.

Note that in this case I just modified your code to take an argument for
the number of bottles just for laughs. If I were optimizing I'd do
something like:

function beerMe3 numberOfBottles
   repeat with N = numberOfBottles down to 0
      put N && "bottles of beer on the wall" & cr & cr & \
            N && "bottles of beer on the wall" & cr & \
            N && "bottles of beer" & cr & \
            "Take one down, pass it around" & cr after theSong
   end repeat
   return line 3 to -5 of theSong
end beerMe3



More information about the use-livecode mailing list