Computer Science Canada how can i errortrap a string |
Author: | goroyoshi [ Thu Mar 03, 2011 8:08 pm ] | ||
Post subject: | how can i errortrap a string | ||
What is it you are trying to achieve? I would like to error trap a string What is the problem you are having? I HAVE NO IDEA HOW TO DO IT! Describe what you have tried to solve this problem nothing (please read above comment) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | Tony [ Thu Mar 03, 2011 8:21 pm ] |
Post subject: | Re: how can i errortrap a string |
goroyoshi @ Thu Mar 03, 2011 8:08 pm wrote: I HAVE NO IDEA HOW TO DO IT!
You can start by describing what error trapping a string means. |
Author: | goroyoshi [ Thu Mar 03, 2011 8:23 pm ] |
Post subject: | Re: how can i errortrap a string |
alright, i already have an errortrap for my integers (when you put text/decimal it will say please enter an integer) so i want it that when you enter for the string "difficulty" that if its wrong or is a number, it will say please enter one of the three options clear? |
Author: | ihsh [ Thu Mar 03, 2011 11:34 pm ] | ||||||
Post subject: | Re: how can i errortrap a string | ||||||
First, I think you should let difficulty be an int variable. That way you don't have to worry about the person typing the word in capital letters. Also, I don't think arrays are necessary here because you are only going to use the variables to store one value each. Furthermore, your code is a bit long. The only difference between the three difficulty levels is the range of the random number, yet you are having three almost-identical sections of code under each condition. You could just make a variable for upper-limit of the random number and save yourself some space. Anyway, suppose that you are just adding the errortrap without changing any other part of the code there are many ways that you can choose, for example: 1. Use procedures
2. Without procedures:
3. Without procedures (II):
|