Computer Science Canada Error proofing user input |
Author: | tecnikal [ Sat May 30, 2009 1:19 pm ] |
Post subject: | Error proofing user input |
My program asks for a user to input integer values. Is there a way, just in case a user inputs a real number with decimal places, to make the program check if it is a real number or an integer value? The numbers MUST be integer values otherwise it will mess up the program. |
Author: | DtY [ Sat May 30, 2009 1:38 pm ] |
Post subject: | RE:Error proofing user input |
the function strintok(String):Boolean will tell you if it can be converted to an integer. |
Author: | Dusk Eagle [ Sat May 30, 2009 3:47 pm ] |
Post subject: | Re: Error proofing user input |
So, as DtY implied, you should get the input as a string and then use strintok (input), strint (input), strrealok (input), and strreal (input) to convert the variable to the appropriate type. |
Author: | DtY [ Sat May 30, 2009 3:52 pm ] |
Post subject: | Re: Error proofing user input |
Dusk Eagle @ Sat May 30, 2009 3:47 pm wrote: So, as DtY implied, you should get the input as a string and then use strintok (input), strint (input), strrealok (input), and strreal (input) to convert the variable to the appropriate type.
Oh yah, I should have mentioned you need to get input as a string. Thanks |