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.
how to convert a c variable into a flowcode variable
Moderator: Benj
-
- Flowcode V4 User
- Posts: 12
- Joined: Sat Nov 21, 2009 4:16 pm
- Contact:
how to convert a c variable into a flowcode variable
- Attachments
-
- c_var_flowc_var.fcf
- (5 KiB) Downloaded 420 times
- 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
Hello,
If you look at the generated C code then you can see how the C variable is represented compared to the Flowcode variable.
So I would get rid of this line.
And then change this line
to this
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;
Code: Select all
unsigned int test =0;
Code: Select all
test=test+1;
Code: Select all
FCV_TEST = FCV_TEST + 1;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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
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
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
-
- 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
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
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
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode V4 User
- Posts: 12
- Joined: Sat Nov 21, 2009 4:16 pm
- Contact: