-- define the standard HTTP header
set LF to ASCII character (10)
set CR to return
set CRLF to CR & LF
set http_10_header to "HTTP/1.0 200 OK" & CRLF & Â
"Server: MacHTTP" & CRLF & Â
"MIME-Version: 1.0" & CRLF & Â
"Content-type: text/html" & CRLF & CRLF
if http_search_args = "" then
-- http_search_args is empty; request input via ISINDEX
return http_10_header & Â
"
" & Â
"Play the Name Game" & Â
"" & Â
"Play the Name Game
" & Â
""
else
-- get our name
set theName to word 1 of http_search_args as string
-- initalize some variables for the next routine
set foundVowel to 0
set theCounter to 0
set theSuffix to theName
-- work through the name until we find the first vowel
repeat until foundVowel is greater than 0
-- increment our counter
set theCounter to theCounter + 1
-- get the next character
set theCharacter to the first item of theSuffix
-- check whether or not it is a vowel
if "aeiouy" contains theCharacter or "AEIOUY" contains theCharacter then
-- found it, exit
set foundVowel to 1
else
-- left-hand truncate the name
set theSuffix to items 2 through length of theSuffix as string
end if
end repeat
-- compose the ryhmes
set ryhmeOne to "B" & theSuffix
set ryhmeTwo to "F" & theSuffix
-- return the lyrics
return http_10_header & Â
"
" & Â
"The Name Game" & Â
"" & Â
"The Name Game
" & Â
"" & theName & ", " & theName & ", Bo " & ryhmeOne & ".
" & return & Â
"Bananna fana, Fo " & ryhmeTwo & ".
" & return & Â
"Fe Fi Fo, " & ryhmeTwo & ".
" & return & Â
"" & theName & "!" & Â
"" & Â
""
end if