Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RND doesn't accept brackets (*solved*)
#1
I've just realized RND() is not accepted ("Unexpected token '(' <LP>"), but only RND. I know it doesn't have parameters in Sinclair BASIC, but it's a function anyway. In fact, both INKEY and INKEY() are accepted, and the case is analogous.

I took a look at the functions list of the original ZX Spectrum manual (page 198, Spanish edition), and realized that PI is there! I never thougth it was a function, but a constant. Well, I tried PI() Smile in ZX BASIC and it's not accepted, not a surprise.

It's clear PI is a constant (that's the description in the wiki), but what's the difference between RND and INKEY? They both are functions that need no parameter. I think RND() should be accepted, if only for syntax coherence.

(I've just read the FreeBASIC's RND syntax. It's accepted without brackets, but can have an optional parameter, the seed.)
Reply
#2
:!: :!: Didn't know that. Anyway, optional parenthesis will be added to RND and PI. And use RANDOMIZE to set the seed as always.

Note: RND is a much efficient and improved random function: It's MUCH faster than ZX Spectrum ROM's one and produces different random sequences than ROM.
It's randomness is also much better (try plotting points at random x,y coords, and they look really random whilst in Sinclair BASIC diagonal lines begin to appear: this means there's a correlation between x, y points hence not very random :wink: ).

Also, Sinclair BASIC RND has a periodicity of 2^16 (65536) sequences, whilst ZX BASIC RND has a periodicity of 2^32 (4,294,967,296) len sequence!!
Reply
#3
boriel Wrote::!: :!: Didn't know that. Anyway, optional parenthesis will be added to RND and PI.

I don't see the point of letting brackets with PI, because it's a constant. Besides, they wouldn't improve any kind of compatibility, neither backward nor forward.
Reply
#4
programandala.net Wrote:
boriel Wrote::!: :!: Didn't know that. Anyway, optional parenthesis will be added to RND and PI.

I don't see the point of letting brackets with PI, because it's a constant. Besides, they wouldn't improve any kind of compatibility, neither backward nor forward.
Yes, my mistake. I misunderstood you. I've checked it anyway: PI does not allow parenthesis. RND does. And that's it (already fixed in the zxbasic/trunk -svn)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)