Page 1 of 1
PI or not PI, that is the question.
Posted: Mon Jan 22, 2018 12:56 am
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:
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.
Re: PI or not PI, that is the question.
Posted: Mon Jan 22, 2018 1:03 am
by rcade
Loop variables can only be one character.
Re: PI or not PI, that is the question.
Posted: Mon Jan 22, 2018 9:53 am
by siggi
Variables can also contain SPACES:
Re: PI or not PI, that is the question.
Posted: Mon Jan 22, 2018 10:29 pm
by PokeMon
There is a distinction between keywords and plain letters.
So PI is not PI (P and I).
Also this is valid
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 ...
Re: PI or not PI, that is the question.
Posted: Wed Jan 24, 2018 10:11 pm
by Shaun_B
You can also do this:
Code: Select all
1 LET APPLE PI = 3.14
2 PRINT APPLEPI
Regards,
Shaun.
Re: PI or not PI, that is the question.
Posted: Mon Jan 29, 2018 3:35 am
by gammaray
That is just so wrong!
Re: PI or not PI, that is the question.
Posted: Mon Jan 29, 2018 9:49 am
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 ....
Siggi