Page 1 of 1

Building string in one or more steps

Posted: Sat Aug 03, 2019 7:30 pm
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 310 times

Re: Building string in one or more steps

Posted: Sun Aug 04, 2019 5:33 am
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

Re: Building string in one or more steps

Posted: Sun Aug 04, 2019 8:31 am
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

Re: Building string in one or more steps

Posted: Sun Aug 04, 2019 10:08 am
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

Re: Building string in one or more steps

Posted: Wed Aug 07, 2019 10:56 am
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.