RE: Live Tutoria?
- Posted by don cole <doncole at pacbell.net> Jan 22, 2006
- 494 views
Lynn Kilroy wrote: > > I do have a question. Inkey outputs an integer, which is good because > all my filters use the integer values for sorting out the keys. But > this is also bad because I try using ColorLocatePrintTextOnly, and > ColorLocatePrintTextOnly, as in QBasic, expects only a string. How do I > fix this? > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy > > I posted some code explaning that but you said it was all greek to you. I will try again with further explination. You wanted to know if Esc was 27 in euphoria like Q Basic this code will answer that question.
------------------code------------------ ---ascii.ex find the ascii code of a keystroke include get.e -- the wait_key function is in here include graphics.e --the colors are in here integer key--declare our only vriable while 1 =1 do--loop to keep doing wait_keys text_color(BRIGHT_BLUE)--purty stuff puts(1,--prints to the screen(1) text "[F1](315)to Exit ")--the text actually printed puts(1,"< Hit Any Key >")--note the lack of any "\n"(carriage return or next line) --so both puts are printed on the same line key = wait_key()--returns an integer if key=315 then --if it is asc for F1 then quit program exit end if text_color(WHITE)--more purdy stuff printf(1,--print formatted to the screen(1) "\nprintf sequence=%s",--a carriage return folowed by th text 'printf sequence=' --The % means the next letter will not be printed --%s is a code to tell euphoria the way it will be printed --in this case %s means sequence or string --the %s will be printed to the screen as a string {key})--this is what %s interpets --in this case key as text or string or sequence --if the 'f' key was struck then 'f' would be printed printf(1,--same as above "\nprintf decimal=%d\n",--same as above but noice that the %s has been changed --to %d the code to tell euphoia to print as a decimal -- note the carriage return "\n" here {key}) --so if the 'f' key was struck the 102 would be printed here. printf(1,"ascii=%d\n",{key}) printf(1,"euphoria expresion=%d\n",{key}) end while
I would like to point out that ?a is the same as printf(1,"%d",a) and puts(1,a} is the same as printf(1,"%s",{a}) You should really study the help file on printf. I really like David Gay's tutorial in the archives (witten in dos) http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=gay One more thing the code that Jason Gade sent you, input() will handle long strings like Qbasic's INPUT whare as my code only handles one chr at a time. I would also point out that a string always = sequence but a sequence does not always = a string.(Again see Gay's tutorial) I know this might be a bit much but I hope it helps. I like your idea of sticking with Dos for now. That what I did when I first started w/Euphoria. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.