Page 1 of 1

ZX81 basic: running the program without clearing variables

Posted: Fri Aug 03, 2018 8:18 pm
by hjalfi
So ZX81 Basic, unusually, allows modification of the program without clearing all the variables; and SAVE and LOAD will save them and reload them.

Except, RUN implicitly does a CLEAR, wiping them before the program runs.

Given that the ZX81 does (AFAIK) allow autorunning of programs, how does this make loading variables off tape useful? Where there any titles where the instructions to start the program told you to do GOTO 0 instead of RUN?

(Why, yes, I am desperately trying to save space in a program; why do you ask?)

Re: ZX81 basic: running the program without clearing variables

Posted: Fri Aug 03, 2018 11:03 pm
by PROSM
Well, you would have to write something like this for an auto-running program that did not clear the variables:

Code: Select all

10 SAVE "PROGRAM"
20 ... (rest of the program here)
To save the program, you type GOTO 10 (so as not to clear the variables) and the SAVE command will be executed. Due to the way ZX81 Basic works, the current state of the BASIC program will be saved, thus when this example is loaded back in, it will automatically start at line 20, believing that it has just finished the SAVE command from line 10.

Re: ZX81 basic: running the program without clearing variables

Posted: Sat Aug 04, 2018 4:53 am
by djnzx48
Is that why so many ZX81 listings from magazines have something like

9996 STOP
9997 CLEAR
9998 SAVE "THING"
9999 GO TO 1

at the end of them? For example this one.

Some listings even made you type in the LET statements yourself before using GO TO to start the program.

Re: ZX81 basic: running the program without clearing variables

Posted: Sat Aug 04, 2018 2:30 pm
by 1024MAK
Yes :D

Part of the system variable area gets saved, and that includes the state of the execution of the BASIC program.

Mark

Re: ZX81 basic: running the program without clearing variables

Posted: Sat Aug 04, 2018 4:04 pm
by hjalfi
Oh, yeah, I completely forgot you could do that! Except it didn't save the GOSUB stack along with the program state, hence the warning in the manual...

Gosh, I'd forgotten how... opinionated... ZX81 Basic is. Also slow.

Incidentally, several of the programs in that issue of _Sinclair Programs_ are incorrectly labelled as for the ZX81 when they clearly only run on the Spectrum. I'm appalled at the lack of professionalism. Should I write in and complain?

Re: ZX81 basic: running the program without clearing variables

Posted: Sat Aug 04, 2018 9:08 pm
by 1024MAK
One thing to keep in mind with the ZX81, is that in SLOW mode, the CPU is spending a lot of it's time sending screen data to the TV. It runs a bit faster in FAST mode (but without a screen display). But even then, the BASIC is pedestrian. The code in the ROM was written to be compact rather than fast, the idea being to squeeze in as much functionality as possible.

Mark

Re: ZX81 basic: running the program without clearing variables

Posted: Sat Aug 04, 2018 11:23 pm
by hjalfi
I don't think 'pedestrian' is the right word --- that implies it's somehow ordinary, which ZX81 Basic is anything but.

I think my favourite combination of features are the absence of multiple statements per line and the missing ELSE clause in if statements: these synergise beautifully for maximum inconvenience... I used to think Commodore Basic was tough to work in! Actually writing a useful program on an unexpanded ZX81 is an interesting challenge (I must try it on some of my cow orkers).

I know there's a cottage industry of alternative ROMs for the Spectrum; did anyone ever do any for the ZX81? Not counting the Jupiter Ace, of course.

Re: ZX81 basic: running the program without clearing variables

Posted: Thu Aug 09, 2018 10:34 am
by 1024MAK
Browse Sinclair ZX World forums, as that is where Zeddy folk hang out :mrgreen:

There have and still are people who have/are improving the BASIC for the ZX81. I can't remember if there is a whole alternative BASIC though.

There is however a ZX Spectrum "emulator" that runs on a ZX81!

Mark