Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How To Limit Text Input ?

Author
Message
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 27th Sep 2004 04:07
I've been using the INPUT command to let users type a username for a program account, but the bug surfaces when they decide to type in like a 200 character username and it stretches way off the screen. I found one work around this but that is to save the massive username$ to a file then read in only the first 22 characters of it, dropping the rest, but this does not solve the bug of text running all over the GUI while they're typing it in.

Does anybody have a good method of limiting user input?

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 27th Sep 2004 04:49
About the best way to do that is to build your own input system, one that limits the number of characters that may be entered;

name$=""
loop0:
a$=inkey$()
if a$="" then goto loop0
if a$=chr$(13) then goto loop1
name$ = name$ + a$
print a$;
if a$=chr$(8) then name$=left$(a$,len(a$)-1)
if len(name$) > 19
name$=left$(a$,len(a$)-1)
print chr$(8);
endif
goto loop0
loop1:

or something similar. (You might have to play with that code a bit to get it working right.)
good luck,
S.

Any truly great code should be indisguishable from magic.
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 27th Sep 2004 17:47
or this:




I am not cool anymore... or am I?
http://n0id.proboards28.com/index.cgi - please join
g 0 t H F r 3 a K
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location: USA
Posted: 28th Sep 2004 20:42
thanx guys. i had my algorythm written before you posted n0id but your code still teaches me something very clean snippit. in case anyone is interested, here is what i came up with on this:



thanx again you two!

AMD Athlon XP 2700 (2.17GHz @ 333FSB) 1GB DDR333 RAM & 256MB ATI Radeon 9600 & 2x120GB HDDs one EIDE 133 and one SATA 150 on Gigabyte 7VT600 with MS Windows XP Pro

Login to post a reply

Server time is: 2024-09-23 00:33:25
Your offset time is: 2024-09-23 00:33:25