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

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

Long and ULong variables not working in fc8

Postby kg300 » Sat Oct 13, 2018 7:25 am

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 36 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Long and ULong variables not working in fc8

Postby medelec35 » Sat Oct 13, 2018 9:05 am

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Long and ULong variables not working in fc8

Postby kg300 » Sat Oct 13, 2018 12:36 pm

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 34 times
No_working.fcfx
(9.03 KiB) Downloaded 33 times

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Long and ULong variables not working in fc8

Postby kersing » 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.
These users thanked the author kersing for the post:
medelec35 (Sat Oct 13, 2018 3:32 pm)
Rating: 5.26%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

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

Re: Long and ULong variables not working in fc8

Postby kg300 » Sat Oct 13, 2018 1:17 pm

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 41 times

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Long and ULong variables not working in fc8

Postby kersing » Sat Oct 13, 2018 1:56 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Long and ULong variables not working in fc8

Postby medelec35 » Sat Oct 13, 2018 2:27 pm

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
Should work.png (93.33 KiB) Viewed 1392 times
These users thanked the author medelec35 for the post:
kersing (Sat Oct 13, 2018 3:12 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Long and ULong variables not working in fc8

Postby kg300 » Sat Oct 13, 2018 2:50 pm

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: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Long and ULong variables not working in fc8

Postby kersing » Sat Oct 13, 2018 3:11 pm

See Martins message above your reply.
These users thanked the author kersing for the post:
medelec35 (Sat Oct 13, 2018 3:32 pm)
Rating: 5.26%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis