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 1:52 am

Re: Tricks in BASIC

Post by archmageirvine » Sat Jul 01, 2017 1: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: 1244
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: Tricks in BASIC

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

archmageirvine wrote:
Sat Jul 01, 2017 1: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 71 times

Shaun_B
Posts: 393
Joined: Wed Apr 22, 2009 10:22 am

Re: Tricks in BASIC

Post by Shaun_B » Tue Aug 08, 2017 4: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: 393
Joined: Wed Apr 22, 2009 10:22 am

Re: Tricks in BASIC

Post by Shaun_B » Sat Sep 02, 2017 1: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.

JJH
Posts: 6
Joined: Sun Jan 28, 2018 4:15 pm

Re: Tricks in BASIC

Post by JJH » Wed Feb 07, 2018 12:00 am

Hi

I've not programmed anything in 30 years and am really struggling with many things.
This caught my eye while I was reading a few threads earlier this evening and I wonder if anyone could post an explanation of line 20.
The rest is simple enough to follow and I think I kind of somewhat get it, but not totally, so please assume I know nothing.

10 LET A$=" HELLO USER. THIS IS THE BEST COMPUTER IN THE WORLD. THE SINCLAIR ZX81 "
20 LET A$=A$(2 TO )+A$(1)
30 PRINT AT 10,1;A$(1 TO 30)
40 GOTO 20

Also, if this is covered in the SINCLAIR BASIC manual and anyone knows what page it's on, please let me know that too.

Thanks in advance to anyone that might respond.

JJH
Posts: 6
Joined: Sun Jan 28, 2018 4:15 pm

Re: Tricks in BASIC

Post by JJH » Wed Feb 07, 2018 1:23 am

Must have been extra dozey earlier. I get it now.
@The little basic program is a nice way to achieve a simple text crawl:)

User avatar
Paul
Posts: 911
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Tricks in BASIC

Post by Paul » Wed Feb 07, 2018 6:25 am

Hi jjh
Well you did not give us much time to respond. ;)
Glad you sorted it out.
Sinclair Basic is a little different to others because of the usage of the keyword TO and the omitted parameters.
Kind regards Paul
In theory, there is no difference between theory and practice. But, in practice, there is.

JJH
Posts: 6
Joined: Sun Jan 28, 2018 4:15 pm

Re: Tricks in BASIC

Post by JJH » Wed Feb 07, 2018 11:45 pm

Hi Paul
Thanks for checking it out.
Think I was just super tired last night after work.
It's a great forum/resource going on here that I only stumbled upon just over a week ago.
Lot's of really friendly, passionate it seems like and quick too offer help too.
Cheers!

Post Reply