Re: how do I do a line input in Euphoria?

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

-> ya know, up till now I've only needed single character inputs, or have
-> been using specialized libraries for string and number input (like Dave
-> Cuny's GUI and jiri's font package) I'm writing a program in text mode,
-> and I can't find how to do a simple string or numeric input in the
-> manuals.  How do I do it?
this is what I usually do... but it is (i think) bad programming...
oh well... i'm only an amatuer :)

this code is _totally_ untested...

-- code starts here
include get.e -- for wait_key()

constant EXIT_KEYS = {13}

sequence line -- the line we're creating
integer char -- the last pushed keyboard character pushed

char = wait_key()
while find(char, EXIT_KEYS) = 0 do      -- should it be 0 or -1 ???
        line = append(line, char)       -- add the character to the line
        char = wait_key()               -- wait for next keypress
end while

puts(1, "You Typed:\n" & line)
-- end of code

yes, its ugly, but it works :)

Mike Fowler - mike.fowler at nelsun.gen.nz
  o__ ---
 _,>/'_ ---
(_) \(_) ---

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

Search



Quick Links

User menu

Not signed in.

Misc Menu