How to restrict number of characters for input
Author |
Message |
Da_Big_Ticket
|
Posted: Mon Oct 24, 2005 12:46 pm Post subject: How to restrict number of characters for input |
|
|
Well here I am again asking for your guys help. I am doing a mortgage program and I have different variables for the users name, there telephone number and postal code etc. I have a photoshop'd background so the when the user inputs they are inputting into a box and the white background thing dosent show up. However I would like to restrict the length the input can be so that it does not exceed the box boundaries and that the program will not crash when 255 characters are inputted. Thanks for your help again
Da Big Ticket |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Mon Oct 24, 2005 12:54 pm Post subject: (No subject) |
|
|
use getch in a loop for the input, and manually display the ouput. Alternatively, look into turing's GUI module (check out the turing manual) |
|
|
|
|
![](images/spacer.gif) |
Da_Big_Ticket
|
Posted: Mon Oct 24, 2005 1:15 pm Post subject: (No subject) |
|
|
Ya im not exactly sure about that. I took a look through the manual aboput GUI but im not sure which commands you would use. Could you give an example? or if anyone else has an alternative that would be good also. |
|
|
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Mon Oct 24, 2005 1:27 pm Post subject: (No subject) |
|
|
id use the getch inside the loop, and each time it goes threw add to a counter. then say if counter > 10 then exit, otherwise you'd exit when the user hits enter...
Somthing like that.. |
|
|
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Mon Oct 24, 2005 1:40 pm Post subject: (No subject) |
|
|
code: | setscreen ("noecho")
var ch : string (1)
var input : string := ""
const maxIn := 10
drawfillbox (0, 0, maxx, maxy, red)
loop
locate (1, 1)
put input : maxIn ..
locate (1, min (length (input) + 1, maxIn))
getch (ch)
if ch = KEY_BACKSPACE then
if input not= "" then
input := input (1 .. * -1)
end if
elsif ch = KEY_ENTER then
exit
elsif length (input) < maxIn then
input += ch
end if
end loop
locate (maxrow div 2, (maxcol - length (input)) div 2)
put input .. |
|
|
|
|
|
![](images/spacer.gif) |
|
|