Float to string problem

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
MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Float to string problem

Post by MarkW »

Hi Ben and other guys

Got a major problem. Using FC4 and just about finished my program/project....with
a hiccup at 12th hour. The project calls for sending a string out the serial port
that is generated from float calculations. I did see a post somewhere that the
float to string is internally limited by integer data type. I need to have a float
to string routine that can handle maybe up to 7 or 8 digits in the whole part
of the number.

Problem is i cannot goto FC5 just yet, as this project is already stressed
timewise and i do not have enough time to sort out new licences/code
porting etc etc....

Guys, i am really in a pickle here. This is the last project i am doing using FC4
so i really need a solution urgently.
After this i am will be going to FC5 which i believe supports long type var
for the whole variable.

Help!

Thanx

Mark

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 to string problem

Post by Benj »

Hello Mark,

Please make a backup of the internals.h file located in the "Flowcode v4/FCD" folder and then replace the file with the file located here.
internals.h
(73.23 KiB) Downloaded 294 times
This should allow up to 7 digits on the whole number though I have not tried a compile.

Let me know how you get on.

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: Float to string problem

Post by MarkW »

Hi Ben

I had an idea the internals needed some surgery :)

anyway, i did try with new internals file but it gives compile error....

Float_test3.c
Starting preprocessor: c:\PROGRA~1\MATRIX~1\FLOWCO~2\boostc\pp.exe Float_test3.c -i c:\PROGRA~1\MATRIX~1\FLOWCO~2\boostc\include -d _PIC18F2610 -la -c2 -o Float_test3.pp -v -d _BOOSTC -d _PIC18 -d _CHAR_INDEX


.............

C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:15): error: unknown identifier 'FCI_LONG_TOSTRING'
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:15): error: failed to generate expression
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:15): error: invalid operand 'FCI_LONG_TOSTRING(whole, temp_string, 7)'
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1483:13): error: failed to generate expression
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h(1485:18): warning: local variable 'str_length' may be used uninitialized
Float_test3.c success

failure

Return code = 1

Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.

FINISHED


Can you give it another go? I have a test file if you want to use that to compile with. It is a very simple program.

Cheers

Mark

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: Float to string problem

Post by MarkW »

Hi Ben

Simple float to str test program

Mark
Attachments
Float_test3.fcf
(7 KiB) Downloaded 296 times

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 to string problem

Post by Benj »

Hi Mark,

This new one seems to compile correctly now.
Attachments
internals.h
(73.3 KiB) Downloaded 295 times

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: Float to string problem

Post by MarkW »

Hi Ben

Big improvement! I can now get up to 6 whole digits....

however, i still need 7 to 8 digits....if i goto 1 million on
the whole, it puts in odd char in digit 6...the zero following the 1
as in 1 millon

I am actually testing on 18F2620 with 232 chip to hyperterm.
Everything works great but see example output on hyperterm

START TEST (1 x 999999)
999999.000000
OK


START TEST (1 x 1000000)
1:00000.000000
Not OK

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: Float to string problem

Post by MarkW »

Hi Ben

Any further progress on the fix for the corrupt 6th digit when doing
7 digit string?

If we can sort that out it will be champion :D

Thanx

Mark

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 to string problem

Post by Benj »

Hello Mark,

Sorry for the delay.

Here is a file that should hopefully work a bit better.
internals.h
(73.48 KiB) Downloaded 310 times
If there is still an issue then look at line 1505 and edit it to this.

Code: Select all

str_length = FCI_LONG_TOSTRING(whole, temp_string, 8);		//Convert integer numbers to strings

MarkW
Flowcode v5 User
Posts: 118
Joined: Thu Sep 17, 2009 1:30 pm
Has thanked: 3 times
Been thanked: 11 times
Contact:

Re: Float to string problem

Post by MarkW »

Hi Ben,

That did the trick thanx :D
My apologies for asking for rapid answer, had unusually tight deadline.

This project is now complete, and will be moving onto FC V5...yay!
Consider that another sale in the bag for MM :D

For all those observing this thread, you may use this latest attached
internals.h file to achieve larger float to string in FC4 due to
Benj's great support.

Thank you very much!

Mark

Post Reply