Load and immediately run a ZX81 Basic program

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
loftcat
Posts: 19
Joined: Fri Mar 26, 2021 12:52 am
Location: Warwick, UK
Contact:

Load and immediately run a ZX81 Basic program

Post by loftcat »

Apologies in advanced if this seems like a straight-forward question, I've looked in the ZX81 Basic manual and can't find the answer...

Is it possible to save a Basic program so when it's loaded back in it runs immediately, rather like in Spectrum Basic by using SAVE "NAME" LINE 10 ?

Thanks!
User avatar
1024MAK
Posts: 5102
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Load and immediately run a ZX81 Basic program

Post by 1024MAK »

ZX81 BASIC Manual wrote:LOAD & SAVE can also be used in programs. With SAVE, the program will save itself in such a state then when loaded it will immediately carry on executing from the line after the SAVE statement.
See Chapter 16 - Tape storage

So to jump to a line number, use a GO TO after the SAVE:

Code: Select all

9050 SAVE “myprog”
9060 GO TO 10
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.
User avatar
BarryN
Posts: 151
Joined: Thu Nov 09, 2017 11:34 pm

Re: Load and immediately run a ZX81 Basic program

Post by BarryN »

Basically you save the program from within itself while it is running. Since it was saved in a running state it continues running when loaded back in.

10 PRINT "HELLO"
20 GOTO 10
100 SAVE"RUNNING"
110 GOTO 10

RUN 100
loftcat
Posts: 19
Joined: Fri Mar 26, 2021 12:52 am
Location: Warwick, UK
Contact:

Re: Load and immediately run a ZX81 Basic program

Post by loftcat »

Perfect just what I was looking for thank you both.

Rechecked the manual too and found the page you're referring to in Chapter 16... I must have missed that page, thanks again!
Post Reply