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

Username:   Password: 
 RegisterRegister   
 Limiting Get Statements to a certain amount of letters
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Joe Keller




PostPosted: Thu Jan 19, 2012 10:09 pm   Post subject: Limiting Get Statements to a certain amount of letters

What is the problem you are having?
Okay so my problem is that I am asking the user to enter his initials, and i want to limit it so that he cant enter more than 2 letters, because i have a background space in which only that many letters can fit in, so if i enter J.K. it'll fit, but Joe K wont so when i say: get username, how do i limit it so that the user cant enter more than two letters.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


<Add your code here>
 get username    <--- %when i draw it down there the name can go on really long, i want to limit it so that it can only be like 2 or 3 letters, so some idiot doesnt enter Joe K thinking thats his initials
    var font4 : int
    font4 := Font.New ("Arial:20")
    Font.Draw (username, 65, 115, font4, 7)

Sponsor
Sponsor
Sponsor
sponsor
crossley7




PostPosted: Thu Jan 19, 2012 10:21 pm   Post subject: RE:Limiting Get Statements to a certain amount of letters

try to have something like this

Turing:

var initials : string (2) % The 2 means the size of the string is only 2 characters.
get initials


You could also read in as characters, etc. A few different ways around the problem
Alex C.




PostPosted: Thu Jan 19, 2012 10:21 pm   Post subject: RE:Limiting Get Statements to a certain amount of letters

well put the get statement in a loop, then an if statement that checks "if length (username) >= 2 then blah-blah elsif length (username)= 2 exit loop

something like that... Look up the proper syntax! Very Happy

EDIT: ...damn i got beat
Joe Keller




PostPosted: Thu Jan 19, 2012 10:24 pm   Post subject: RE:Limiting Get Statements to a certain amount of letters

Thanks Alot Guys, I really appreciate it, and Both of you were an incredible help!
Tony




PostPosted: Thu Jan 19, 2012 10:25 pm   Post subject: RE:Limiting Get Statements to a certain amount of letters

you can try reading the documentation for get -- it talks about just this.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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: