Building string in one or more steps

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

Moderator: Benj

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Building string in one or more steps

Post by Jan Lichtenbelt »

I wanted a string which is the sum of 4 other strings.

First I did it in one step like

STRING = str1+ str2+str3+str4 (1)

This works in simulation, but gave the wrong result in practice with the microchip.
Buiding the string step by step results in the correct string. Like

STRING= str1
STRING= STRING+str2
STRING= STRING+str3
STRING= STRING+str4 (2)

What is the reason of the wrong results of (1)?

Kind regards

Jan
Test_Timer1_V3.fcfx
(11.16 KiB) Downloaded 187 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Building string in one or more steps

Post by chipfryer27 »

Hi Jan

This is a known "feature" of Flowcode and has been brought up a few times. The recommended way to concatenate is how you did it in your working example.

I'm sure a search of the forum will explain why, and sorry that I don't have time at present to supply a link to such.

Regards

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Building string in one or more steps

Post by mnf »

It 'compiles' to

Code: Select all

    FCI_SHEAD(FCV_TEMPERATURE_STR,FCVsz_TEMPERATURE_STR, " ",2, FCI_TMP_STR,20);
    FCI_SHEAD(FCI_TMP_STR,20, FCI_TOSTRING(FCV_ALARM_TIME, FCI_TMP_STR,20),20, FCI_TMP_STR,20);
    FCI_SHEAD(FCI_TMP_STR,20, " M",3, FCV_TEMP_STR,20);
- it looks like FC is attempting to use FCI_TEMP_STR for multiple purposes - so for example in line 2 - it is used in FCI_TOSTRING to get the string value of FCV_ALARM_TIME - but is already in use as the temporary result string.

Martin

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Building string in one or more steps

Post by Jan Lichtenbelt »

Hi Martin

The second line declares the error result I get, which shows the Alarm_Time to preceed all other strings.

FCI_SHEAD(FCI_TMP_STR,20, FCI_TOSTRING(FCV_ALARM_TIME, FCI_TMP_STR,20),20, FCI_TMP_STR,20);
Kind regards

Jan

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: Building string in one or more steps

Post by Benj »

Hello,

We've had this one on the list for a while now. It certainly does need fixing but there may be a cost in terms of bloating the RAM usage to allow us to buffer all the intermediary steps. I'll see if we can do anything to try and bump this one up so we can fix it.

Post Reply