Computer Science Canada Avoiding Crashes |
Author: | noob [ Sun Mar 16, 2003 8:45 am ] |
Post subject: | Avoiding Crashes |
I'm trying to avoid crashes due to bad data input, but I don't seem to know how to do it. I want to get the name of a person, and check the length of the name. For ex. I want the name to be less than 25 characters long, but in turing if someone enters one more than 25 letters, there's an error leading back to the code, I want to know how to output the error onto the run window saying its too long and have them re-input the name. Thanks for the help in advance. |
Author: | azndragon [ Sun Mar 16, 2003 9:39 am ] | ||
Post subject: | |||
This should help.
This makes it so that it keeps on asking their name, until it's less than or equal to 25 characters. When that happens, it exits the loop, and will do whatever comes after it. Hope this helps. Edit: Dan - gave some bits to him for helping |
Author: | noob [ Sun Mar 16, 2003 10:43 am ] |
Post subject: | |
Thanks a lot |
Author: | jamez [ Sun Mar 16, 2003 11:29 am ] | ||
Post subject: | |||
or just
Didn't need that xtra var Edit: Dan - gave bits for helping |
Author: | azndragon [ Sun Mar 16, 2003 11:47 am ] |
Post subject: | |
Yeah, that's actually better, but I like using tons of variables for some reason. Keeps the program more organized. |