Computer Science Canada allow the user to input a space when getting a string |
Author: | DanceMacabre [ 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? |
Author: | [Gandalf] [ Sun Aug 20, 2006 1:38 pm ] | ||||
Post subject: | |||||
This belongs in [Turing Help], not [Turing Tutorials]. Next time post there.
After the colon, you specify how many characters are to be entered, for example:
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. |
Author: | Cervantes [ Sun Aug 20, 2006 2:31 pm ] |
Post 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. |
Author: | Clayton [ Sun Aug 20, 2006 3:22 pm ] |
Post 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 |
Author: | richcash [ Sun Aug 20, 2006 4:10 pm ] |
Post 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). |