Tricks in BASIC

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
archmageirvine
Posts: 1
Joined: Sat Jul 01, 2017 12:52 am

Re: Tricks in BASIC

Post by archmageirvine » Sat Jul 01, 2017 12:55 am

I have an article describing a lot of these memory saving techniques and their history.

See: https://mega.nz/#!ioVzgDLa!Vmb4uS9c4Ivz ... wETip0tSp8

RWAP
Site Admin
Posts: 1231
Joined: Thu May 08, 2008 7:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: Tricks in BASIC

Post by RWAP » Sat Jul 01, 2017 7:28 am

archmageirvine wrote:
Sat Jul 01, 2017 12:55 am
I have an article describing a lot of these memory saving techniques and their history.

See: https://mega.nz/#!ioVzgDLa!Vmb4uS9c4Ivz ... wETip0tSp8
Welcome to the forums - that is quite an interesting short article - I have uploaded it here to make it easier to accesss
Attachments
zx81-memory.pdf
(104.14 KiB) Downloaded 43 times

Shaun_B
Posts: 312
Joined: Wed Apr 22, 2009 9:22 am

Re: Tricks in BASIC

Post by Shaun_B » Tue Aug 08, 2017 3:28 pm

Type this:

Code: Select all

LET A$="DONKEYSOFT"
in direct mode, and then:

Code: Select all

10 PRINT A$;" ";
20 GOTO 10
9998 SAVE "D"
9999 GOTO 10
Do not try RUNning the listing, instead type:

Code: Select all

GOTO 9998
As you will see, the file will save everything including the variable stack. So that means - if you are careful - you may type in your variables in direct mode and use them in your program. It also means that if someone breaks your program to hack it, and types RUN, the var stack will be wiped.

Regards,

Shaun

Shaun_B
Posts: 312
Joined: Wed Apr 22, 2009 9:22 am

Re: Tricks in BASIC

Post by Shaun_B » Sat Sep 02, 2017 12:20 pm

I haven't thought of a practical use for it yet, but this is possible:

Code: Select all

  10 LET I=CODE "4"
  20 FOR I=I/I TO I
  30 PRINT I,;
  40 NEXT I
So you're re-using I in place of the start and end of the loop counter, and declaring I as the scalar value for the FOR/NEXT loop.

Regards,

Shaun.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests