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

Username:   Password: 
 RegisterRegister   
 allow the user to input a space when getting a string
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DanceMacabre




PostPosted: Sun Aug 20, 2006 1:15 pm   Post subject: allow the user to input a space when getting a string

How do i make it so that when i input a string, the program can also recieve spaces as well as characters w/o seeing each seperate set of characters as two completely different inputs?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sun Aug 20, 2006 1:38 pm   Post subject: (No subject)

This belongs in [Turing Help], not [Turing Tutorials]. Next time post there.

code:
var name : string
put "Enter your full name: " ..
get name : *

After the colon, you specify how many characters are to be entered, for example:
code:
get postalCode : 6 %6 characters should be entered

And since the * symbol is generally regarded as a wildcard, it allows the user to enter the maximum possible amount of characters (in Turing), which is 255.
Cervantes




PostPosted: Sun Aug 20, 2006 2:31 pm   Post subject: (No subject)

Moved.

Also note that using '255' instead of '*' is better, as using '*' does not prevent the user from crashing the program by inputting more than 255 characters.

At least, that's what I recall.
Clayton




PostPosted: Sun Aug 20, 2006 3:22 pm   Post subject: (No subject)

no i think inputting over 255 characters in a string using the get statement followed by :* will still cause an error and cause Turing to crash, theres really nothing you can do to error trap that unless you keep count of the length of the string after each input and if it exceeds 255 characters then create another variable or disallow input
richcash




PostPosted: Sun Aug 20, 2006 4:10 pm   Post subject: (No subject)

Quote:
no i think inputting over 255 characters in a string using the get statement followed by :* will still cause an error and cause Turing to crash


As Cervantes said.

Quote:
theres really nothing you can do to error trap that unless you keep count of the length of the string ...


Yes, you can prevent the program from crashing by following a get statement with a :255. The string will still only keep the first 255 characters in memory, but the user can input as many as he/she wants and there will be no error (Turing will not crash).
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: