Decimal Point in LCD

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
iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Decimal Point in LCD

Post by iain wilkie »

Bit stuck here ! .... I have an INT variable ... it can only be 0 to 9999, but I want to display it as 0.000 to 9.999
How do I output it to the LCD in this format ?

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times

Re: Decimal Point in LCD

Post by JohnCrow »

One easy way is to convert the interger to a string
Split using left$ and right $
Print string onthe LCD Int part, print a "." then print the decimal

Ive attached a very simple exmple of how to manipulate strings.

I suppose the other way would be to convert to a float and then divide by 10 or 100 ect .
But then you would still have to convert float to string to display on the lcd

Hope this helps
Attachments
split string.fcf
(6.5 KiB) Downloaded 413 times
1 in 10 people understand binary, the other one doesn't !

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Decimal Point in LCD

Post by iain wilkie »

That works fine for numbers like 1234 but a nuber like 55 needs to display as 0.055 ....

Iain

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Decimal Point in LCD

Post by Dan81 »

Hello Iain

In a calculation :

TH = N DIV 1000
var = N MOD 1000
HND = var DIV 100
var = var MOD 100
TEN = var DIV 10
UNT = var MOD 10

then

PRINT_NUMBER (TH)
PRINT_ASCII (',')
PRINT_NUMBER (HND)
PRINT_NUMBER (TEN)
PRINT_NUMBER (UNT)



Daniel

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Decimal Point in LCD

Post by iain wilkie »

Thanks guys ... found another solution,

The max value is 9999 so all I do is add 10000 to the value so I know it will always be 5 digits.
Then int = mid$(val,1,1)
and dec = right$(val,3)

Then just output to lcd int "." dec

Cheers

Post Reply