
-----------------------------------
noobsauce
Thu Oct 09, 2008 5:56 pm

Limiting input
-----------------------------------
How do i limit the input to for example 3 characters without like doing a string and ignoring everything after the 3rd part.

-----------------------------------
[Gandalf]
Thu Oct 09, 2008 6:06 pm

RE:Limiting input
-----------------------------------
Not sure exactly what you're looking for, but a loop with getch() or Input.KeyDown() would work.

-----------------------------------
noobsauce
Thu Oct 09, 2008 6:20 pm

Re: Limiting input
-----------------------------------
What i am asking is that if for example, i ask for someone's student number. 
I know it is 9 digits, how do I prevent the user from entering over 9 digits?

-----------------------------------
Tony
Thu Oct 09, 2008 6:24 pm

RE:Limiting input
-----------------------------------
you ask for the input 1 character at a time (using getch()) and keep a count of how much the user has entered so far.

-----------------------------------
Insectoid
Thu Oct 09, 2008 6:25 pm

RE:Limiting input
-----------------------------------
Use getch () in a for loop, and add the input to a string. This way, you can getch 9 times, and it will automatically end the getting.

-----------------------------------
noobsauce
Thu Oct 09, 2008 8:03 pm

Re: Limiting input
-----------------------------------
Thanks for the reply guys, I really appreciate it.
I have another problem
I need the user to input a name, first and last, but the get statement only gets the info until the space, so the last name is ignored, how do I get the full name in 1 string?

-----------------------------------
Insectoid
Thu Oct 09, 2008 8:09 pm

RE:Limiting input
-----------------------------------
when typing multiple words into a string, you need to put quoteations around them. 

input (Harold Haselhoff) will return 'Harold', while input ("Harold Haselhoff") will return Harold Haselhoff.

-----------------------------------
Clayton
Thu Oct 09, 2008 8:16 pm

RE:Limiting input
-----------------------------------
Actually, not quite. get only captures input up to the first whitespace in the string that it's trying to capture from. To counter this, you'll need to use:

var foo : string := "";
get foo :*;


the :* following the get statement will make sure that you capture all input that the user provides, even whitespce.

-----------------------------------
Insectoid
Thu Oct 09, 2008 8:23 pm

RE:Limiting input
-----------------------------------
I've always used quotations, but then, I never knew you could do it your way. Oh, well, Turing is behind me. 

But quotations will cancel out the 'no white space' thing.

-----------------------------------
noobsauce
Thu Oct 09, 2008 8:36 pm

Re: Limiting input
-----------------------------------
nvm, i figured out how to do it. Thanks guys

-----------------------------------
rto
Fri Oct 10, 2008 8:12 am

RE:Limiting input
-----------------------------------
For reference, you could also make a second variable. might take a bit of extra time but no extra steps are needed in the inputting stage
