CuriousOne
- 22nd December 2023, 07:09
Hello.
I have some code, which, based on value of the X variable (changes from 1 to 30)
Should call some GOSUBs as shown below:
IF X=1 THEN GOSUB ONE
IF X=2 THEN GOSUB ONE: GOSUB TWO
IF X=3 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE
IF X=4 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE: GOSUB ONE
IF X=5 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE: GOSUB ONE: GOSUB TWO
IF X=6 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE: GOSUB ONE: GOSUB TWO: GOSUB THREE
This is from 1 to 6, but I have to do it up to 30, and there it gets way too long. So maybe there's some way to make things less complex?
One way I see it to create another set of GOSUBs, each for group of 3, like
[code]
ONE-X:
GOSUB ONE
RETURN
TWO-X:
GOSUB ONE: GOSUB TWO
RETURN
THREE-X:
GOSUB ONE: GOSUB TWO: GOSUB THREE
RETURN
[code]
But how to "split" the X in the proper way?
So for example, when X=8, THREE-X will be called 2 times and ONE-X - 1 times?
I have some code, which, based on value of the X variable (changes from 1 to 30)
Should call some GOSUBs as shown below:
IF X=1 THEN GOSUB ONE
IF X=2 THEN GOSUB ONE: GOSUB TWO
IF X=3 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE
IF X=4 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE: GOSUB ONE
IF X=5 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE: GOSUB ONE: GOSUB TWO
IF X=6 THEN GOSUB ONE: GOSUB TWO: GOSUB THREE: GOSUB ONE: GOSUB TWO: GOSUB THREE
This is from 1 to 6, but I have to do it up to 30, and there it gets way too long. So maybe there's some way to make things less complex?
One way I see it to create another set of GOSUBs, each for group of 3, like
[code]
ONE-X:
GOSUB ONE
RETURN
TWO-X:
GOSUB ONE: GOSUB TWO
RETURN
THREE-X:
GOSUB ONE: GOSUB TWO: GOSUB THREE
RETURN
[code]
But how to "split" the X in the proper way?
So for example, when X=8, THREE-X will be called 2 times and ONE-X - 1 times?