Cool ZXers,
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 (lines 10-30) in another loop (if that's the most elegant approach), so it does:
6
7
8
9
10
The next time I run it. And so on, each time I run it, the sequence is iterated.
Learning BASIC is fun, but I'm stubbing my toe here and I would appreciate your advice.
Thank you.
KB
How to iterate the iteration
- 1024MAK
- Posts: 5103
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: How to iterate the iteration
If you keep your program as it is, instead of using RUN to run it a second (or third) time, you instead use GO TO 15, it will do what you want. You will need to add a CLS or a SCROLL to prevent running into the bottom of the screen if you use GO TO 15 too many times though.
Mark
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
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.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
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.
Re: How to iterate the iteration
Hi Mark,
Thank you for taking time to reply, but I am aware of that method. I am interested in solving this concept.
Cheers,
KB
Thank you for taking time to reply, but I am aware of that method. I am interested in solving this concept.
Cheers,
KB
Re: How to iterate the iteration
10 LET X=1
15 FOR X = X TO X+5
20 PRINT X
30 NEXT X
40 GOTO 35
15 FOR X = X TO X+5
20 PRINT X
30 NEXT X
40 GOTO 35
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: How to iterate the iteration
You folks that know BASIC well may indeed be slapping your foreheads at my question...I keep thinking there is a nested solution, or something else.
Thanks again for taking a look.
KB
Thanks again for taking a look.
KB
- 1024MAK
- Posts: 5103
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: How to iterate the iteration
As BASIC variables are CLEARed when RUN is used, if you wish to retain a value in between RUNs, you can store it in an area of RAM that BASIC will leave alone.
So for example, on a ZX81, in a REM statement in the first line of a program. Note that I entered POKE 16514,0 as a direct statement before running it, but if you use the appropriate character in the REM line, you don’t have to. If you wish to edit the REM line, it’s best to enter it afresh rather than edit it in case the number/character upsets the editor. Mark
So for example, on a ZX81, in a REM statement in the first line of a program. Note that I entered POKE 16514,0 as a direct statement before running it, but if you use the appropriate character in the REM line, you don’t have to. If you wish to edit the REM line, it’s best to enter it afresh rather than edit it in case the number/character upsets the editor. Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
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.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
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.
Re: How to iterate the iteration
The main question is : "How to save the "Vars" memory room in Basic ?" to retrieve an ancien memory variables snap...
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: How to iterate the iteration
or...
10 LET Z=16417
15 FOR X = PEEK(Z) TO PEEK(Z)+5
20 PRINT X
30 NEXT X
35 POKE Z,X
37 CLS
40 GOTO 35
10 LET Z=16417
15 FOR X = PEEK(Z) TO PEEK(Z)+5
20 PRINT X
30 NEXT X
35 POKE Z,X
37 CLS
40 GOTO 35
Xavier ...on the Facebook groupe : "Zx81 France"(fr)