Conditions with GOSUBS?? Is this right?
Blitz3D Forums/Blitz3D Beginners Area/Conditions with GOSUBS?? Is this right?
| ||
Conditions within GOSUBS. My question is If every GOSUB in my game has conditional statements within them, should I use a WHILE WEND loop for every gosub? In other words, is it better to use the WHILE WEND or REPEAT UNTIL command in a GOSUB LOOP? For example Graphics3d 800,600 ;;load images, sounds, etc ;main loop While key down(1)=0 If this condition is true then gosub1 ; If this condition is true then Gosub2 ; Wend .Gosub1 While x>10 and sec>10 cls ;Do this ;paste image10 ;user clicks a button ;user inputs a answer Endif wend return While b>15 and tec>12 cls ;Do this ;paste image15 ;user clicks a button ;user inputs a answer Endif wend return ;etc other gosub ;other conditional statements |
| ||
I would cut the Gosub all together. In my opinion, anything that you can do with a gosub\goto loop, you can do a lot better using functions. So my advice would be to replace the gosubs, with functions. And as to your question about while loops, I usually use while loops instead of Repeat Until loops. They are simply easier to use. Hope this helps you, The Mighty WERDNA(Lord Of Darkness) |
| ||
As much as it pains me to say it, WERDNA is right. Forget about Gosub and use functions. |
| ||
agreed, I would also look at using types instead of arrays as well. Arrays still have thier use of course, but I find that using types cut my array use down to 0 or 1 an entire project and I had far more control. |
| ||
Thanks for the info. I guess I will stick with functions. |
| ||
Here is an excerpt from my programming tutorial on loops: So, why do we have all of these different kinds of loops? They are there to make programming easier. Each one can probably do what the others can do. They each just do it a little bit differently. We can pick and choose which one works best for us. Repeat-Until loops are usually used when we want the loop to execute at least one time. While-Wend loops are usually used when we don't want the loop to execute unless the While is true. This means they may not execute at all. For-Next loops are usually used to cause a counter to increase/decrease incrementally a certain amount of times. http://myweb.arvig.net/rwolbeck1/programmingtutorial/tutorial/loops.htm |