Conditional Steps
BlitzMax Forums/BlitzMax Beginners Area/Conditional Steps
| ||
I have a for - Next Loop with a large chunk of code in it. Depending on the circumstance I either want the Step value to be 1 or 3, but Step is a constant so I can't set it to a variable. I don't want to repeat all the code, so was wondering if there is a way to set the step value according to my circumstance, or whether I need to use a different type of loop. |
| ||
Could you...mystep=3 For x = 1 To 20 Print x x=x+mystep Next ? |
| ||
Hello. 1) Use an If-Then and have two separate loops. 2) Don't use a for-next, use a while-wend/repeat-until and set the step yourself. Goodbye. |
| ||
Yep - thanks guys, I changed it to use a While loop and set the step myself. |