Computer Science Canada case sector is out of range |
Author: | HaVoC [ Fri Dec 05, 2003 2:08 pm ] | ||
Post subject: | case sector is out of range | ||
It says case sector is out of range, what does this mean, and what do I do to fix it? Also my random number code doesn't work.... randomize randint(number,1,1000) What's wrong with this? |
Author: | Andy [ Fri Dec 05, 2003 2:12 pm ] |
Post subject: | |
cuz u dont have case 2, or 3, or 5 or anything except 100,200,300,400,500,600,700,800,900,1000, just have it from 1 to 10 or have num:=Rand.Int(1,10)*100 |
Author: | Mazer [ Fri Dec 05, 2003 2:16 pm ] | ||
Post subject: | |||
you need another label at the end to handle every other option. meaning, if boundary is anything other than what you have there, the case needs to know what to do:
also, don't use randomize at the beginning of your program, turing uses it automatically every time the program is run. |
Author: | HaVoC [ Fri Dec 05, 2003 2:17 pm ] | ||
Post subject: | |||
Ok so it'd be
|
Author: | Mazer [ Fri Dec 05, 2003 2:24 pm ] | ||||
Post subject: | |||||
eh? not quite sure what you're asking there. just add
after all of your other labels, and before the end case line. for example, if you had
at the end of the case statement thingy, and you ran the program and boundary was 5 or something else that you didn't check for in the case statement the program would put "enexpected case" on the screen |
Author: | HaVoC [ Fri Dec 05, 2003 2:25 pm ] |
Post subject: | |
Ok I got my case statements to work, but I still have a problem. I chose my number as a fixed value as 777. But it didn't say I am choosing a number between 1 and 800. -.- I think i'm missing something in my case statement ![]() |
Author: | HaVoC [ Fri Dec 05, 2003 2:35 pm ] | ||
Post subject: | |||
And also how do you end the program? it's in an if statement
|
Author: | Andy [ Fri Dec 05, 2003 2:49 pm ] |
Post subject: | |
if ur not in a procedure, the return command exits the program instantly |
Author: | Mazer [ Fri Dec 05, 2003 3:09 pm ] | ||
Post subject: | |||
HaVoC wrote: Ok I got my case statements to work, but I still have a problem. I chose my number as a fixed value as 777. But it didn't say I am choosing a number between 1 and 800. -.- I think i'm missing something in my case statement
![]() i think you're trying to use that case statement to check if the number is in a range of values, aren't you? for this (and everything, really) it's better to use if statements. that way:
that should work out much better. |
Author: | HaVoC [ Fri Dec 05, 2003 3:18 pm ] |
Post subject: | |
I'm trying to mae it so that the random number goes into the boundary. Say the random number was 99 it's day label 100: "i chose a numebr between 1 and 100" |
Author: | Mazer [ Fri Dec 05, 2003 3:48 pm ] |
Post subject: | |
yes, just use the if statements that i had in the last post. |
Author: | Dan [ Fri Dec 05, 2003 5:06 pm ] |
Post subject: | |
Mazer wrote: ....for this (and everything, really) it's better to use if statements.
well it dose wrok well for user menuns and anything where you the exacte posable values of the thing being tested. but it is true that it is not need, i bet if you where able to look at the socre code for it, it whould just be some if stamnets. (that or they just uses c++ switch direlty ![]() |
Author: | HaVoC [ Fri Dec 05, 2003 10:48 pm ] | ||
Post subject: | |||
Ok and 1 last thing. My randint code ain't working. I think i'm missing somehting
|
Author: | HaVoC [ Fri Dec 05, 2003 10:52 pm ] | ||
Post subject: | |||
dodge_tomahawk wrote: if ur not in a procedure, the return command exits the program instantly
I have code after it though So I have this
I have code after that if incase he doesn't get it right, it asks for guess2. How can I make the program end if he get's it right? |
Author: | Dan [ Sun Dec 07, 2003 1:29 am ] |
Post subject: | |
well i am not shure where your ifs are but i am guesing they are in a loop of some kind, in that case you can probly added an exit stament to quite the loop. |