PI or not PI, that is the question.

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

PI or not PI, that is the question.

Post by Shaun_B »

Hi,

I've noticed that on ZX81 BASIC, I can use PI as a variable name (not the token PI), like this:

Code: Select all

     1 LET PI=3.14
     2 PRINT PI
However, I can't use PI in a FOR loop, like:

Code: Select all

     1 FOR PI=0 TO 3
     2 PRINT PI
     3 NEXT PI
Is this a limitation of the FOR command (i.e., can you only use single-character variable names in FOR loops)?

Thanks,

Shaun.
rcade
Posts: 26
Joined: Tue Dec 02, 2014 2:28 pm

Re: PI or not PI, that is the question.

Post by rcade »

Loop variables can only be one character.
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: PI or not PI, that is the question.

Post by siggi »

Variables can also contain SPACES:

Code: Select all

10 LET NOT PI = 0
20 PRINT NOT PI
:mrgreen:
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: PI or not PI, that is the question.

Post by PokeMon »

There is a distinction between keywords and plain letters.
So PI is not PI (P and I).
Also this is valid :lol:

Code: Select all

10 LET LET=99
20 PRINT LET
30 LET PRINT=88
40 PRINT PRINT

I guess this is handled wrong with the ZX-IDE but this unusual programming style ... ;)
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: PI or not PI, that is the question.

Post by Shaun_B »

You can also do this:

Code: Select all

     1 LET APPLE PI = 3.14
     2 PRINT APPLEPI
Regards,

Shaun.
User avatar
gammaray
Posts: 590
Joined: Sun Apr 17, 2016 2:44 am
Location: Texas

Re: PI or not PI, that is the question.

Post by gammaray »

That is just so wrong!
5-TS1000,UK ZX81<-Sheelagh, US ZX81, 2-TS1500/KDLX , 3-TS2040 printer, 2-TS2020 cassette decks, ZXPAND+AY, ZeddyNET, ZXBlast, UDG, ZX8CCB, AERCO, BUILDS/REPAIRS ZX Spectrum, ZX80 Minstrel, ZXMAX48 v1 v2, 2-TS-2068, ROM, 16kRAM
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: PI or not PI, that is the question.

Post by siggi »

Re: PI or not PI, that is the question.
The real question is

Code: Select all

10 if two beer or not two beer ....
:mrgreen:
Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
Post Reply