Re: Euphoria ASCII function revisited

new topic     » goto parent     » topic index » view thread      » older message » newer message

Steve Elder wrote:
>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.

  Your code was a little "beefed up", I guess you could say.  It would be=

easier, instead of using all of the functions you did, to do something li=
ke
this:
--------------------------------------Start of
Code-------------------------------------------------------------
include get.e

object k

while 1 do
   puts(1,"\nEnter y/n  ")
   k =3D wait_key()
   if k =3D 'y' or k =3D 'Y' then
      puts(1,"\nyes")
      exit
   elsif k =3D 'n' or k =3D 'N' then
       puts(1,"\nno")
       exit
   else
        puts(1,"You must enter y or n")
end while

printf(1,"You entered %s as the answer.",k)

--------------------------------------End of
code----------------------------------------------------------------

It's easier to just put it all in one while loop rather than use up extra=

memory and time with the functions.  Also, it's easier to put the letters=

in single quotes than to look up all the ASCII numbers, as 'Y' is equal t=
o
121 (I think).  I hope this helps.

Regards,
 Bryan Watts

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu