Pages: 1
Topic closed
I would like to write an IF statement with a long list of ORed values e.g
If Something = 1 or 2 or ...or 1023
Is there an easy way of doing this? I have tried nested OR statements but this becomes very slow after a few ORs and scrolling to the right is no fun. I nearly a list of hundred values each time.
Offline
You could simply have the if statements sequentially, without needing "Or", by having the triggered action be a broadcast.
If X=1
- Broadcast "Doaction
- Stop Script
If X=2
- Broadcast "Doaction
- Stop Script
If X=3
- Broadcast "Doaction
- Stop Script
You could also cover multiple values with one statement. For example, this one will trigger for 1,2,3,4,5,6,7,8 and 9.
If x>0 and X<10
- Do action
Offline
Thanks Mayham but i was hoping for an IN statement like in SQL
If Something IN (1,2,3..) (May be they will add this at some point.
My problem is that I have hundred a 1023 values grouped into some 34 groups and the numbers are not sequential either so I can not use the second suggestion.
I have also tried the non nested route and by grouping them by 5 etc. not to repeat the couple of lines every time. Even with a 130 or so in the processing is slowing down and I am afraid I might choke it with the 1023 if conditions nested or not..
Offline
I'm intrigued - what exactly is this project doing with all these variables?
Offline
Dear Mayham,
Check out http://www.galaxy.gmu.edu/~drsuper/product.html#I I had a version of this game written fro me in VB and since last week that I discovered Scratch I am doing it now in Scratch my self. Essentially I have identified each state of the Super Board by 1 and 0 so I have 1023 states and I need to tell the board to go from each state to a next state (I know the full strategy) The game was published by Creative Publications but it is discontinued;=<
When I put over 300 if statements in the Stages Scratch chokes but I have distributed them over the ten board triangle now and it seems to hold up. I am not done yet.
I looked at your work and it looks great. I got to learn to do animations.
My ambition is to develop a full curriculum in games for elementary and middle school Math in Scratch and for OLPC.
Regards
Behrouz Aghevli
a.k.a. Dr. Super
baghevli2@worldbank.org
Offline
Topic closed
Pages: 1