RND function

Everything related to BASIC version 1.x (Oric 1 and Atmos) or HYPERBASIC (Telestrat).
Don't hesitate to give your small program samples, technical insights, or questions...
Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

RND function

Post by Chris »

Oric doesn't like the following line despite the fact it's in the manual!

A = INT(RND(I)*6+1

(taken from page 66 for the curious)
What's wrong here? I tried putting all of the sample program on Oric and it came back with an error on this line.
User avatar
Pengwin
Pilot Officer
Posts: 69
Joined: Sun Jan 07, 2007 11:03 pm
Location: Scotland
Contact:

Post by Pengwin »

There is an error on that page, it should read

Code: Select all

40 A = INT(RND(1)*6)+1
Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

Post by Chris »

It's interesting that the Oric manual would have a typo. Also interesting is how a simple closed parenthesis would make a computer not behave the way it's supposed to. That fixed my problem. Thanks Pengwin.
User avatar
Pengwin
Pilot Officer
Posts: 69
Joined: Sun Jan 07, 2007 11:03 pm
Location: Scotland
Contact:

Post by Pengwin »

One of the things to remember about programming in almost any language is that certain characters must always have a 'pair'. Parentheses is one as are braces, quotes and square brackets.
Kronos
1st Star Corporal
Posts: 9
Joined: Tue Jun 19, 2007 11:13 am

Post by Kronos »

sorry to hijack the thread, but since it is related, I might as well post it here.

x=int(rnd(1)*100)+1

that should make x always be between 1 and 100

Now, on the MacOSX version of the emulator, it always comes back with the same number.
even after re initializing the emulator.
As we know, RND produces pseudo random numbers, but it should have changed it time for x (when looped).
Is this a bug in the emulator, or does anyone remember a BASIC command to initialize the RND function.
On some machines it used to be RANDOMIZE (or RAND)
not so in Oric basic.
RND(0) use to work on other machines.
It has been about 25 years, if anyone remembers how to reinitialize the RND function, please let me know.
(was it a POKE somewhere??)
Thanks!
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema »

Kronos wrote:sorry to hijack the thread, but since it is related, I might as well post it here.

x=int(rnd(1)*100)+1

that should make x always be between 1 and 100

Now, on the MacOSX version of the emulator, it always comes back with the same number.
even after re initializing the emulator.
As we know, RND produces pseudo random numbers, but it should have changed it time for x (when looped).
Is this a bug in the emulator, or does anyone remember a BASIC command to initialize the RND function.
On some machines it used to be RANDOMIZE (or RAND)
not so in Oric basic.
RND(0) use to work on other machines.
It has been about 25 years, if anyone remembers how to reinitialize the RND function, please let me know.
(was it a POKE somewhere??)
Thanks!
I have tested this on Euphoric and it works for me, so it must be an error on the emulator.

However beware that the parameter has a somewhat strange meaning. If I remember correctly RND(1) generates random numbers between 0 and 1, and that is the only way to generate them. I mean passing RND(4) does not generate numbers between 0 and 4.

The parameters worked on an akward way, such as RND(0) generating the last computed random number again (?) and using a negative param doing other strange things... better check the manual (you can found it online here in defence-force).

I think there is no way of reestarting the number generator with an initial seed from BASIC, but maybe a POKE could do something... can't help in this point.

Hope this helps... somehow... :)

Cheers
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol »

Chris wrote:It's interesting that the Oric manual would have a typo. Also interesting is how a simple closed parenthesis would make a computer not behave the way it's supposed to. That fixed my problem. Thanks Pengwin.
That's not the only one ;)

In the french Atmos Manual, the same mistake appears on two different pages (pictures here at the bottom of the page : http://www.oricgames.com/forum,fr,66,109,1.html )

It is dealing with the CSAVE of the hires screen :

Code: Select all

CSAVE "FileName",A40960,E48000
The fact it appears on two different pages make me think thzat it is more than a typo, and that there is also the same mistake in the English manual .
:wink:

I leave you find where is the "bug"
Brana
Flying Officer
Posts: 169
Joined: Fri Nov 30, 2007 8:30 pm
Contact:

Re

Post by Brana »

The same typo regarding the CSAVE function is present in Croatian translation of Oric Atmos manual (the book that came with my Oric Atmos)
on Croatian language!

Because of this error in the manual it took me rather long time to realise how to CSAVE a HIRES screen! :(
Post Reply