RANDOM

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
electron67
Posts: 323
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 106 times
Been thanked: 48 times

RANDOM

Post by electron67 »

How use Random; CALCULATION: A0 = RANDOM()
Simulation is Ok, but when copile, is error (support technical)

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: RANDOM

Post by Steve »

Hello.

We need a bit more information to help you with this. Which software product are you using (and which version)?

Also, please attach a program to this forum which exhibits this problem.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: RANDOM

Post by medelec35 »

Steve.
You can replicate the issue using latest version of Flowcode V4 (not tried with other versions). Use the Random() function within a calculation box.

Code: Select all

Launching the compiler...

C:\Program Files\Matrix Multimedia\Flowcode V4\BoostC\boostc.pic16.flowcode.exe -v -t PIC16F88 "Random Number Error.c"

BoostC Optimizing C Compiler Version 6.95 (for PIC16 architecture)

http://www.sourceboost.com

Copyright(C) 2004-2009 Pavel Baranov

Copyright(C) 2004-2009 David Hobday



Licensed to FlowCode User under Single user Pro License for 1 node(s)

Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited





Random Number Error.c

Starting preprocessor: C:\PROGRA~1\MATRIX~1\FLOWCO~2\BoostC\pp.exe "m:\Random Number Error.c" -i C:\PROGRA~1\MATRIX~1\FLOWCO~2\BoostC\include -d _PIC16F88 -la -c2 -o "m:\Random Number Error.pp" -v -d _BOOSTC -d _PIC16 





..............



m:\Random Number Error.c(80:19): error: unknown identifier 'rand'

m:\Random Number Error.c(80:19): error: failed to generate expression

m:\Random Number Error.c(80:19): error: invalid operand 'rand()'

m:\Random Number Error.c(80:17): error: failed to generate expression

Random Number Error.c success



failure



Return code = 1



Flowcode was unable to compile the flowchart's C code due to the following errors:





If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.



FINISHED
Attachments
Random Number Error.fcf
(3 KiB) Downloaded 337 times
Martin

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: RANDOM

Post by Steve »

I see the problem. To use the random number function, you will need to add the following line to the "defines" section of the supplementary code:

Code: Select all

#include <rand.h>
random_header.png
(52.94 KiB) Downloaded 3328 times

electron67
Posts: 323
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 106 times
Been thanked: 48 times

Re: RANDOM

Post by electron67 »

:idea: Tank you for the answer, I can read good english, but not very well write english.
In the future, I write in spanish :?:

Tank you

Post Reply