Hi,
I'm trying to get a random number on a led array. In a calculation I'm using output = random(). This works fine in the simulation.
Boostc translates this into the operand rand() but when translating into asm the following errors appear:
error: invalid operand 'rand()'
error: failed to generate expressioninvalid operand 'rand()'
How can this be solved?
Thanks
Jef Schoonis
random() function
Moderator: Benj
-
IVL
- Posts: 17
- Joined: Sat Sep 17, 2011 7:10 pm
- Location: Belgium
- Has thanked: 8 times
- Been thanked: 5 times
Re: random() function
Hi,
I'm not sure about Flowcode, but most programming languages expect a "seed" value to be used.
So, try to use random(256) instead of random.
This would mean a random value between 0 and 256 -1 will be returned.
Regards,
Ivan
I'm not sure about Flowcode, but most programming languages expect a "seed" value to be used.
So, try to use random(256) instead of random.
This would mean a random value between 0 and 256 -1 will be returned.
Regards,
Ivan
- JohnCrow
- Valued Contributor

- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
Re: random() function
Hi Jef
Have a look at this post.
It has a flowcode program with an example of using the random function.
http://www.matrixmultimedia.com/mmforum ... 967#p22091
Edit:
Dont forget to put the following statement in the supplimentary code box
#include <rand.h>
Otherwise the program wont work
Have a look at this post.
It has a flowcode program with an example of using the random function.
http://www.matrixmultimedia.com/mmforum ... 967#p22091
Edit:
Dont forget to put the following statement in the supplimentary code box
#include <rand.h>
Otherwise the program wont work
1 in 10 people understand binary, the other one doesn't !
-
Jef_S
- Flowcode v5 User
- Posts: 5
- Joined: Sun Oct 05, 2008 4:28 pm
- Has thanked: 3 times
- Been thanked: 1 time
Re: random() function
Hello Ivan,IVL wrote:Hi,
I'm not sure about Flowcode, but most programming languages expect a "seed" value to be used.
So, try to use random(256) instead of random.
This would mean a random value between 0 and 256 -1 will be returned.
Regards,
Ivan
Thanks for your input. I tried this but Flowcode does not accept anything between the brackets.
Regards
Jef
-
Jef_S
- Flowcode v5 User
- Posts: 5
- Joined: Sun Oct 05, 2008 4:28 pm
- Has thanked: 3 times
- Been thanked: 1 time
Re: random() function
JohnCrow wrote:Hi Jef
Have a look at this post.
It has a flowcode program with an example of using the random function.
http://www.matrixmultimedia.com/mmforum ... 967#p22091
Edit:
Dont forget to put the following statement in the supplimentary code box
#include <rand.h>
Otherwise the program wont work
Thanks John,
This does the job for me.
Kind regards
Jef