well your code won't work at all for me. And you should document the code so I know what those keystates are. (its not ascii so I can't look them up easily)
The problem is when you press ENTER it's adding that character to the end. You can't see it, but its there.
This works a lot better for me, but even mine seems to not accept what I type every time. Hmm...
do
cls
set cursor 0,0
print "Action: ", command$
rem get keyboard input
command$ = ENTRY$(1)
rem user presses ENTER key
if keystate(28) = 1 and flag = 0
flag = 1
command$ = lower$(left$(command$, len(command$)-1))
select command$
case "newb"
pop = pop+1
endcase
case "newg"
pop2 = pop2+1
endcase
case "exit"
end
endcase
endselect
clear entry buffer
endif
IF returnkey() = 0 then flag = 0
set cursor 0,20
print pop
print pop2
loop
Ok, far as I can tell, when I use LEFT$ to remove the carriage return, it doesn't always do it. Sometimes it takes off the last character. So I'm thinking the carriage return isn't always being added to the string.
Something like this should work:
if asc(mid$(command$, len(command$))) = 13 then command$ = left$(command$, len(command$)-1)
I think there's a bug in DBP, because I can't seem to make a pattern here. Sometimes the carriage return is there, sometimes it's not. Other times I don't know what it's doing.
Use this example and type "dog" a few times. You'll see the length of the word dog is sometimes 3, 4, or even 5!
clear entry buffer
pop = 5
pop2 = 7
do
cls
set cursor 0,0
print "Action: ", command$
rem get keyboard input
command$ = ENTRY$()
rem user presses ENTER key
if keystate(28) = 1 and flag = 0
flag = 1
command$ = lower$(command$)
`if asc(mid$(command$, len(command$))) = 13 then command$ = left$(command$, len(command$)-1)
in$ = command$
select command$
case "newb"
pop = pop+1
endcase
case "newg"
pop2 = pop2+1
endcase
case "exit"
end
endcase
endselect
clear entry buffer
endif
IF returnkey() = 0 then flag = 0
set cursor 0,20
print pop
print pop2
print
`if asc(mid$(in$, len(in$))) = 13 then in$ = left$(in$, len(in$)-1)
print in$
print len(in$)
print asc(mid$(in$, len(in$)))
loop
Only way around this is to write a custom function to make sure all characters in the string are valid at the ascii-level.
"You're not going crazy. You're going sane in a crazy world!" ~Tick