Hi BASIC Brains,
I am trying to get my head around iterating something that is already iterating. Hmm, I hope that made sense. Well, let's say I have this:
10 LET X=1
15 FOR T = 1 TO 5
20 PRINT X
25 LET X=X+1
30 NEXT T
RUN
1
2
3
4
5
But what if I want the whole thing to iterate, so it does:
6
7
8
9
10
The next time I run it. Yes I could add a GOTO at the end, but that's not what I'm after.
Thank you fine folks, I appreciate your time.
KB
Iterating the iterator
Re: Iterating the iterator
Maybe not quite what you wanted, but you can do this at least:
10 LET X=1
15 FOR X=X TO X+5
20 PRINT X
30 NEXT X
40 GO TO 15
As FOR-NEXT loop variables can be used just like normal variables, here X is being used to initialise itself in the loop. Also you can use GOTO instead of RUN to run a program, which stops the variables from being cleared.
10 LET X=1
15 FOR X=X TO X+5
20 PRINT X
30 NEXT X
40 GO TO 15
As FOR-NEXT loop variables can be used just like normal variables, here X is being used to initialise itself in the loop. Also you can use GOTO instead of RUN to run a program, which stops the variables from being cleared.
Re: Iterating the iterator
RUN clears all the variables, so if you want to do this you either have to avoid using it to restart the program or CLEAR memory to give you some free bytes and then POKE/PEEK numbers from there, beyond the reach of what BASIC will interfere with.
- 1024MAK
- Bugaboo
- Posts: 3123
- Joined: Wed Nov 15, 2017 2:52 pm
- Location: Sunny Somerset in the U.K. in Europe
Re: Iterating the iterator
Standby alert
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: Iterating the iterator
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Re: Iterating the iterator
Yes,
I asked it for the Atari too:
http://atariage.com/forums/topic/288390 ... -iterator/
Each community has its bright lights, each with their own style of answering. Answers can be like books, some connect with you and some don't. I am determined to finish this game idea. At first I wanted to make a sell-worthy game for the TS1000, but then I fell in love with the Spectrum, and I want the game to have some square wave sound effects.
Thank you.
KB
I asked it for the Atari too:
http://atariage.com/forums/topic/288390 ... -iterator/
Each community has its bright lights, each with their own style of answering. Answers can be like books, some connect with you and some don't. I am determined to finish this game idea. At first I wanted to make a sell-worthy game for the TS1000, but then I fell in love with the Spectrum, and I want the game to have some square wave sound effects.
Thank you.
KB