float point in properties

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

float point in properties

Post by Rudi »

hi guys
no hurry,

discover just the "diversity" ( vielvalt )
and stumble a bit.

how do I get the float results in the properies advertisement?
floating_properties.png
so far I only get completely charged at a calculation.
if I have a float test number Enter H in the formula,
then it is displayed.
what am I doing wrong?

Code: Select all

.tmpCPUCLK = ::Component .Property .GetValue (this,"FCV_CPUCLK")
.tmpPREDIV = ::Component .Property .GetValue (this,"FCV_SPI_CLK_PREDIV")
.tmpCNTDIV = ::Component .Property .GetValue (this,"FCV_SPI_CLK_CNTDIV")

.tmpCPUCLK_HZ = .tmpCPUCLK * 1000000
.tmpSPICLKFREQ = .tmpCPUCLK_HZ / (.tmpPREDIV * .tmpCNTDIV)

::Component .Property .SetValue (this,"FCV_SPI_CLK_FREQ", .tmpSPICLKFREQ)


.tmpCPUCLK_HZ = .tmpCPUCLK
.tmpSPICLKFREQ_MHz = .tmpCPUCLK_HZ / (.tmpPREDIV * .tmpCNTDIV)

// will be a int
::Component .Property .SetValue (this,"FCV_SPI_CLK_FREQ_MHz", .tmpSPICLKFREQ_MHz)

// only for a Test: will be a int in properties
// ::Component .Property .SetValue (this,"FCV_SPI_CLK_FREQ_MHz", (10 / 3))

// only for a Test: will be a float in properies
// ::Component .Property .SetValue (this,"FCV_SPI_CLK_FREQ_MHz", 3.1428 )


thanks!
best wishes
rudi ;-)
Last edited by Rudi on Tue Jun 21, 2016 9:04 pm, edited 1 time in total.

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: float point in properties

Post by Benj »

Hi Rudi,

Assuming .tmpCPUCLK_HZ,.tmpPREDIV and .tmpCNTDIV are integers try typecasting to a float.

Code: Select all

.tmpSPICLKFREQ_MHz = FLOAT .tmpCPUCLK_HZ / FLOAT (.tmpPREDIV * .tmpCNTDIV)
Hopefully this will do the trick, certainly caught me out before.

If this doesn't work then another trick is using constants e.g. instead of 10000 you would use 10000.0 to signify it is a float and perform the typecast.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: float point in properties

Post by Rudi »

Benj wrote:Hi Rudi,

Assuming .tmpCPUCLK_HZ,.tmpPREDIV and .tmpCNTDIV are integers try typecasting to a float.

Code: Select all

.tmpSPICLKFREQ_MHz = FLOAT .tmpCPUCLK_HZ / FLOAT (.tmpPREDIV * .tmpCNTDIV)
Hopefully this will do the trick, certainly caught me out before.

If this doesn't work then another trick is using constants e.g. instead of 10000 you would use 10000.0 to signify it is a float and perform the typecast.

hi benj
thanks for the help!
did not want to disturb you at night. :oops:
exactly brought the desired result, many thanks!
casting_float_did_the_trick.png
just endvertex many things and paths which I had not yet used.
ye have done really great work in the api.
so many possibilities.
hope you can still the EV_replace FC6 realize I, if not, then we are happy with it in the FC7 :wink:

best wishes
rudi ;-)

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: float point in properties

Post by Rudi »


Post Reply