Long and ULong variables not working in fc8

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

Moderator: Benj

Post Reply
kg300
Posts: 31
Joined: Thu May 31, 2018 6:25 am
Has thanked: 5 times
Been thanked: 1 time
Contact:

Long and ULong variables not working in fc8

Post by kg300 »

i am using 30 days trail of fc8. test program working in Fc simulation but not working on physical lcd. string printing is working on physical LCD but Long and Ulong calculation not working.
Attachments
test.fcfx
(9 KiB) Downloaded 208 times

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

Re: Long and ULong variables not working in fc8

Post by medelec35 »

Hi,
For displaying long and ulong numbers and maybe uint instead of using PrintNumber you need to use PrintFormattedNumber
If variable is Ulong then use 1 for format
If variable is long then use 0 for format
Martin

kg300
Posts: 31
Joined: Thu May 31, 2018 6:25 am
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: Long and ULong variables not working in fc8

Post by kg300 »

Still not working. but i think this is problem in calculation icon, when i put value directly in long variable, it display fine, but when i put the SUM of two values in this variable it not exceed more then 32000 (like an Int variable). Is flowcode Trail version support morer then Int Variables??
Attachments
working.fcfx
(8.66 KiB) Downloaded 193 times
No_working.fcfx
(9.03 KiB) Downloaded 203 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Long and ULong variables not working in fc8

Post by kersing »

For math to use long type you need to assign the first value to the long type and then perform the operation on that long type variable. If you multiply two integers the result will be integer and that will be 'expanded' to long. If you assign the value to a long and then multiply the long with an integer the result will be long. (That is standard C practice, not limited to Flowcode)
Applies to all calculations, not only multiplication but addition, subtraction etc.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

kg300
Posts: 31
Joined: Thu May 31, 2018 6:25 am
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: Long and ULong variables not working in fc8

Post by kg300 »

but the same program working fine with FC5, FC6 & FC7, not in FC8. Calculation not exceed more then 32000
:(
Attachments
V6.fcfx
(5.61 KiB) Downloaded 194 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Long and ULong variables not working in fc8

Post by kersing »

Does it work on hardware or in simulation for the other versions?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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

Re: Long and ULong variables not working in fc8

Post by medelec35 »

Hi,
I have to agree with kersing.
BoostC compiler which is all flowcode versions up to and including V6 will work the way you want it to.
All versions V7 or greater will not work unless you do what kersing has suggested since the Ulong is typecast to signed integer.
Can you confirm about v7 working as that uses same compiler as V8.
The way to get it to work could be:
Should work.png
(93.32 KiB) Downloaded 1828 times
Martin

kg300
Posts: 31
Joined: Thu May 31, 2018 6:25 am
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: Long and ULong variables not working in fc8

Post by kg300 »

kersing can u modify it for me.
it working both on hardware and in simulation in fc6.
but in fc8, it simulate ok but not working on hardware. if i do something wrong in fc8 so please modify it for better understand

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Long and ULong variables not working in fc8

Post by kersing »

See Martins message above your reply.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
AbhijitR
Posts: 298
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 279 times
Been thanked: 78 times
Contact:

Re: Long and ULong variables not working in fc8

Post by AbhijitR »

Hello! KERSING
kersing wrote:
Sat Oct 13, 2018 12:44 pm
For math to use long type you need to assign the first value to the long type and then perform the operation on that long type variable. If you multiply two integers the result will be integer and that will be 'expanded' to long. If you assign the value to a long and then multiply the long with an integer the result will be long. (That is standard C practice, not limited to Flowcode)
Applies to all calculations, not only multiplication but addition, subtraction etc.
Many thanks for the post, it worked for me.

Abhi

Post Reply