Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to restrict number of characters for input
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Da_Big_Ticket




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: 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)
Da_Big_Ticket




PostPosted: 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.
TokenHerbz




PostPosted: 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..
beard0




PostPosted: 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 ..
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: