Posts: 1,000
Threads: 253
Joined: Feb 2008
QuickMacros does not have an example for this page:
http://www.99-bottles-of-beer.net/q.html
Posts: 12,073
Threads: 140
Joined: Dec 2002
Macro 99 bottles of beer
;99 Bottles of Beer in Quick Macros
str s
int i
for i 99 -1 -1
,if(i!99) s.addline(F"Take one down and pass it around, {i} bottles of beer on the wall.[]")
,s.addline(F"{i} bottles of beer on the wall, {i} bottles of beer.")
s.addline("Go to the store and buy some more, 99 bottles of beer on the wall.")
s.replacerx("(1 bottle)s" "$1" 2); s.findreplace("[]0" "[]No more"); s.findreplace("0" "no more" 2)
out s
Posts: 1,000
Threads: 253
Joined: Feb 2008
Function 99_Bottles
ARRAY(str) Tens.create(10)
Tens[0]=""
Tens[1]=""
Tens[2]="twenty"
Tens[3]="thirty"
Tens[4]="forty"
Tens[5]="fifty"
Tens[6]="sixty"
Tens[7]="seventy"
Tens[8]="eighty"
Tens[9]="ninety"
ARRAY(str) Ones.create(10)
Ones[0]="no more"
Ones[1]="one"
Ones[2]="two"
Ones[3]="three"
Ones[4]="four"
Ones[5]="five"
Ones[6]="six"
Ones[7]="seven"
Ones[8]="eight"
Ones[9]="nine"
ARRAY(str) Number
for int'i 0 100
,str s=i
,sel s.len
,,case 1
,,Number[]=F"{Ones[i]}"
,,case 2
,,if !(_s.get(s 1 1)=0) and !(_s.get(s 0 1)=1)
,,,Number[]=F"{Tens[val(_s.get(s 0 1))]}-{Ones[val(_s.get(s 1 1))]}"
,,if (matchw(s "1?")) and !(val(s)<=15) or (val(s)=14)
,,,Number[]=F"{Ones[val(_s.get(s 1 1))]}teen"
,,,Number[Number.len-1].findreplace("tt" "t")
,,if val(_s.get(s 1 1))=0 and !(i=10)
,,,Number[]=F"{Tens[val(_s.get(s 0 1))]}"
,,sel i
,,,case 10
,,,Number[]="Ten"
,,,case 11
,,,Number[]="Eleven"
,,,case 12
,,,Number[]="Twelve"
,,,case 13
,,,Number[]="Thirteen"
,,,case 15
,,,Number[]="Fifteen"
for(i 99 0 -1)
,str Verse=(F"{Number[i]} bottles of beer on the wall, {Number[i]} bottles of beer.[]Take one down and pass it around, {Number[i-1]} bottles of beer on the wall.[]")
,Verse.findreplace("one bottles" "one bottle" 2)
,_s.get(Verse 0 1)
,_s.ucase
,Verse.replace(_s 0 1)
,str Song.addline(Verse)
Verse=F"{Number[0]} bottles of beer on the wall, {Number[0]} bottles of beer.[]Go to the store and buy some more, {Number[Number.len-1]} bottles of beer on the wall."
_s.get(Verse 0 1)
_s.ucase
Verse.replace(_s 0 1)
Song.addline(Verse)
out Song
Posts: 12,073
Threads: 140
Joined: Dec 2002
Macro 99 bottles of beer2
;Ninety-nine Bottles of Beer in Quick Macros
str longString=
;no more
;one
;two
;three
;four
;five
;six
;seven
;eight
;nine
;ten
;eleven
;twelve
;thirteen
;fourteen
;fifteen
;sixteen
;seventeen
;eighteen
;nineteen
ARRAY(str) a1=longString
ARRAY(str) a2="[][]twenty[]thirty[]forty[]fifty[]sixty[]seventy[]eighty[]ninety"
str s s1 s2
int i i1 i2
for i 99 -1 -1
,i1=i/10; i2=i%10
,
,if(i<20) s1=a1[i]
,else if(i2) s1.from(a2[i1] "-" a1[i2])
,else s1=a2[i1]
,
,if(i!99) s.addline(F"Take one down and pass it around, {s1} bottles of beer on the wall.[]")
,s2.format("%s bottles of beer on the wall, %s bottles of beer." s1 s1)
,s2[0]=toupper(s2[0])
,s.addline(s2)
s.replacerx("(one bottle)s" "$1" 1)
s.addline("Go to the store and buy some more, ninety-nine bottles of beer on the wall.")
;Show the song
sel list("QM output[]Notepad" "Show the song in")
,case 1
,out s
,
,case 2
,run "notepad.exe" "" "" "" 0x2800 win("Notepad" "Notepad")
,s.setsel
____________________________________
From http://www.99-bottles-of-beer.net/submi ... guage.html
Quote:Keep each line under 100 chars!
Posts: 1
Threads: 0
Joined: Sep 2011
lol..
You can download bot that write the song auto, here.
QM ROCKS!
|