Computer Science Canada Get Value Certain Length |
Author: | l0tt0 [ Thu Oct 23, 2003 4:52 pm ] |
Post subject: | Get Value Certain Length |
Is there anyway taht when you use get variable that it can only be a certain amount of characters? Say I have a yes or no question i just want them to enter y or n... anyone? thanks in advance |
Author: | Tony [ Thu Oct 23, 2003 5:09 pm ] | ||
Post subject: | |||
getch() reads a single character from input buffer. If you want more then a single letter of input, you would run getch in a forloop. |
Author: | PaddyLong [ Thu Oct 23, 2003 8:42 pm ] | ||
Post subject: | |||
a function I just wrote up ... hope it does what you need it will get characters for the string until enter is pressed or until there are the set number of characters. if you want it to keep going even if they push enter (so it will always get exactly the number of characters you specify) then take out the "ord (ch) = 10 or " in the exit statement
|
Author: | hackman [ Mon Oct 27, 2003 11:45 am ] |
Post subject: | |
Not realy relavent but...what dose ch in getch stand for? |
Author: | Tony [ Mon Oct 27, 2003 6:11 pm ] | ||
Post subject: | |||
should have read the whole code first
ch is a name of a variable of string(1) type |
Author: | hackman [ Tue Oct 28, 2003 11:46 am ] |
Post subject: | |
i meant in the getch comand, as in var ans:string (1) getch (ans) |
Author: | Tony [ Tue Oct 28, 2003 5:33 pm ] |
Post subject: | |
ohhh lol ch in "getch" is short for character. |
Author: | hackman [ Wed Oct 29, 2003 10:51 am ] |
Post subject: | |
wohoo my guese was right! |