Originally Posted By: Glenn Barnas
 Code:
; begin BOB
;
;!
function a($)
  Dim $W
  
  $ = 1 * $

  $W = ' on the wall'

  ; build the string
  ; Get the "x bottles of beer" phrase
  $a = W($)
  ; build it, and capitalize the first letter
  $a = UCase(Left($a, 1)) + Right($a, ~) + $W + ', ' + $a + '.'

  ; If $ isn't zero, take one down, otherwise go buy some more!
  If $
    $a = $a + ' Take one down and pass it around, ' + W($ - 1) + $W + '.'
  Else
    $a = $a + ' Go to the store and buy some more, ' + W(99) + $W + '.'

endfunction

Function W($)
  Dim $S
  ; array of number terms
  $S = Split('no more,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir!,#!,fif!,#!,#!,eigh!,#!,,twen,thir,for,fif,,,eigh,', ',')

  If $ < 20
    $W = Replace(Replace($S[$], !, teen), #, $S[$ Mod 10])		; use regular or special number and optional "teen"
  Else
    $W = $S[19 + $/10]							; Get special tens value
    $W = $W + IIf($W, '',$S[$/10]) + ty					; normalize and add "ty"
    If $ Mod 10 $W = $W + '-' + $S[$ Mod 10] EndIf			; add optional hyphen and ONEs digit
  EndIf

  $W = $W + ' bottle' + IIf($ = 1, '', s) + ' of beer'

EndFunction
;!
;!
; end BOB
for 568.


Hey Glenn, your code passed the test but the Score says 571
_________________________