do
do
a$ = inkey$
loop until a$ <> ""
text% = text% + a%
loop
hope this helps. let me explain this.
when a$ = inkey$, this assigns a$ the next key the user types. it exits the loop, and adds the letter the user typed to the array.
but a much easier way is to put this before your code:
color, 0
this makes the font color black.
but you may want to have a flashing _ showing the person he can type, right? so try this.
x = 1 'the x coordinate of the _
y = 1 'the y coordinate of the _
t = 1 'whether the _ is on or off 1 is on 0 is off
do
do
if t = 1 then 'if t is 1...
locate x, y 'it prints the _ and turns t to 0.
print chr$(95) 'prints the _...
t = 0 'turn off t
else 'if t is 0...
color = 0 'turns the color to black
locate x, y 'prints a black _ to cover up the white _.
print chr$(95)
color = 15 'turns color back to white
t = 1 'turns t back to 1.
endif
a$ = inkey$ 'assigns a$ to the next key you press
loop until a$ <> "" 'waits until you press a key
if a$ = chr$(27) then: print text$: end 'if the user presses escape, print text and end the program.
if a$ = chr$(13) then: exit sub 'i dunno if this'll work... if you press enter then it'll exit the sub.
'if a$ = chr$(8) 'i doubt this will work. hypothetically
'texta = len(text$) 'if you press backspace, it'll delete the last letter,
'text$(texta) = text$(texta) - 1 'but i really doubt it'd work.
'you could probably do it with the mid$ command or right$ command... i might try this later.
'that's why the code is REMed. it won't work because text$ is a string not an integer.
b = asc(a$) 'turns b into the asc value of the key you press
if b > chr$(32) and b < chr$(127) and b <> chr$(32) then when you press delete or whatever...
a$ = "" 'turns a$ to nothing.
else
text$ = text$ + a$ 'this adds the letter you press to the array.
loop 'start again.
now, this is just basic. i thought of this off the top of my head. if you know the ascii value of backspace you can delete the last character. here's how you do it. to do this you need to find out how long text$ is then minus one from it. it will delete the last letter. oh, and if the user presses enter, it'll exit the sub. (assuming this is in a sub. and if the user presses space, it'll make a space. you should be able to find out how to restrict how long to make the input. good day.
geeze, that's pretty long. anyways, take what you want, leave the rest. good day!
instead of this... do
do
a$ = inkey$
loop until a$ <> ""
text% = text% + a%
loop
I would use this...
TEXT$ = "" DO
A$ = INKEY$
IF A$ <> ""
SELECT CASE A$
CASE CHR$(27) 'ESC
EXIT DO
CASE CHR$(8) 'BACKSPACE
IF LEN(TEXT$) > 0 THEN TEXT$ = LEFT$(TEXT$,LEN(TEXT$)-1)
CASE CHR$(13) 'ENTER
EXIT DO
CASE ELSE
TEXT$ = TEXT$ + A$
END SELECT
END IF
LOOP UNTIL A$ = CHR$(13)
PRINT TEXT$
[/B]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.