Re: Another How-to Question

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

> Here is what I want to do this time:
>
> Display a prompt and recieve a string in response. Nothing unusual
> about that. Here's the catch. I want to display editable text on the
> screen. Example
>
> What is your name: John Q. Public
>
> I want all of that to be displayed by my program and the user be able
> to backspace/change John Q. Public to their name. For example the
> screen would now look like:
>
> What is your name: John A. Washington

My Euphoria is bad, so I'll give you the algorithm in Commodore 64 BASIC.
Why? Because I have written and rewritten this particular code SO many times
on that particular platform.

10 t$="John Q. Public":p$="What is your name? "
20 print p$;t$;:poke 204,0:rem this is a 64 thing, ignore it
30 get a$:if a$="" goto 30
40 if a$=chr$(20) and len(t$) then print a$" "a$;:t$=left$(t$,len(t$)-1):
   goto30:rem chr$(20) is C64 BKSP, so make it 0x08/0x7f for PC
50 if a$=chr$(13) and len(t$) then poke204,1:print " ":end:rem ignore
   the poke 204,1 again
60 if a$<" "ora$>"z" goto 30:rem character codes 32-90 in PETSCII
70 if len(t$)>30 goto 30:rem arbitrary length of string
80 print a$;:t$=t$+a$:goto 30

Yeah, I realize this is cryptic in parts, but the algorithm is here.
Basically, all it is is a bulletproof shielded INPUT routine.
If you want an exhaustive breakdown, I can do that too, but I think it
explains itself pretty well.

Cameron Kaiser
http://www.sserv.com/
spectre at sserv.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu