Re: Euphoria ASCII function revisited
- Posted by Steve Elder <SteveElde at AOL.COM> Jul 26, 1997
- 1036 views
Why I wanted the ASCII function was to do an if-then from a letter input, such as y for yes and n for no. Here's what I have so far. ---------------------------Cut Here------------------------------------- include get.e function ascii_table(object character) sequence valued_result valued_result = value(sprintf("%d",character)) character = 0 -- convert valued_result to an atom character = character + valued_result[2] return character end function atom yn,yn2 yn2 = 0 puts(1,"\nEnter y/n: ") -- user enters y or n in response to a question yn = wait_key() function ifyn(atom yn) -- convert y or n to ascii yn = ascii_table(yn) return yn end function while 1 do -- test for y or n and output a response if yn = 121 or yn = 89 then -- accept upper or lower case y puts(1, "\nyes") exit elsif yn = 110 or yn = 78 then -- accept upper or lower case n puts(1,"\nno") exit else -- reject all responses except y or n while 1 do puts(1,"\nYou must enter y or n.") yn = wait_key() yn = ascii_table(yn) if yn = 121 or yn = 110 or yn = 89 or yn = 78 then exit end if end while end if end while puts(1,"\nyou entered: ") puts(1,yn) -- output of y or n