how to convert a c variable into a flowcode variable

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
dirkvg@skynet.be
Flowcode V4 User
Posts: 12
Joined: Sat Nov 21, 2009 4:16 pm
Contact:

how to convert a c variable into a flowcode variable

Post by dirkvg@skynet.be »

I start my flowcode program with a c block

unsigned int test=0;
test = test+1;

how can I use that variable in a calculation block?

in my attached file I hoped that on te LCD should come a 2 and not a 1

Thanks in advance for any help.
Attachments
c_var_flowc_var.fcf
(5 KiB) Downloaded 420 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: how to convert a c variable into a flowcode variable

Post by Benj »

Hello,

If you look at the generated C code then you can see how the C variable is represented compared to the Flowcode variable.

Code: Select all

    //C Code
    //C Code:
    unsigned int test =0;
    test=test+1;


    //Calculation
    //Calculation:
    //  test = test+1
    FCV_TEST = FCV_TEST + 1;
So I would get rid of this line.

Code: Select all

unsigned int test =0;
And then change this line

Code: Select all

test=test+1;
to this

Code: Select all

FCV_TEST = FCV_TEST + 1;

dirkvg@skynet.be
Flowcode V4 User
Posts: 12
Joined: Sat Nov 21, 2009 4:16 pm
Contact:

Re: how to convert a c variable into a flowcode variable

Post by dirkvg@skynet.be »

Thanks for your answer but the result is not still good

If you look at my attached program, after the simulation of that program on the LCD comes a 1
and for me it must be a 2
Attachments
c_var_flowc_var1.fcf
(5 KiB) Downloaded 422 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: how to convert a c variable into a flowcode variable

Post by dazz »

Hi
The result is what you are asking for as your variable is 0 so test =test+1 will equal 1, is there any specific reason you are using a c block in your code ??

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: how to convert a c variable into a flowcode variable

Post by Benj »

Hello,

C code will not simulate which is why you are getting 1 instead of 2. Also I would initialise the value before incrementing, in simulation it will initialise to 0 for you but the hardware will not do this and will be random at best.

dirkvg@skynet.be
Flowcode V4 User
Posts: 12
Joined: Sat Nov 21, 2009 4:16 pm
Contact:

Re: how to convert a c variable into a flowcode variable

Post by dirkvg@skynet.be »

Thanks to all for the answers

Post Reply