Page 1 of 1
[Solved] Macro return string longer than 20 characters
Posted: Wed Aug 16, 2017 2:37 pm
by tiny
Is it possible to set a return string of a macro longer than 20 characters?
I am using Flowcode 7, latest version.
Example: Search and Replace a Character in a String. I would like to use this function with some other string manipulations in a component macro.
If I now want to edit strings longer 20 characters with a component macro is not possible.
Thanks
Christina
Re: Macro return string longer than 20 characters
Posted: Wed Aug 16, 2017 3:03 pm
by LeighM
Hi Christina,
You could pass the source string as a parameter into the editing macro.
In the string parameter details, just make sure that the "Make a local copy of the value" is not ticked.
You can then make changes to the string in the macro, no need to return it.
Hope that helps,
Leigh
Re: Macro return string longer than 20 characters
Posted: Wed Aug 16, 2017 3:46 pm
by Docara
HI Tiny,
Just guessing - Could the problem be that FC defaults the string length to 20 characters
After you have setup the string variable go back into it and click on the 20 in the square brackets and change it . I found a similar problem which compiled and simulated correctly but failed in hardware and this was the cause.
Matt
Re: Macro return string longer than 20 characters
Posted: Wed Aug 16, 2017 8:22 pm
by tiny
Thanks for the quick reply!
Could you please show me how this works with parameter transfer? I have simple tools, which I always need again, packed into a component macro. Attached is a small example with the Replace function, but only works with short strings.
Thanks
Christina
Re: Macro return string longer than 20 characters
Posted: Thu Aug 17, 2017 9:48 am
by LeighM
Hi Christina,
Sorry, it looks like we have a bug.
The limiting to 20 characters is being done at the point where the string is returned from the Replace macro.
This is happening for simulation, but looks like it should be OK for downloaded target code.
A workaround for this problem would be to have the Replace macro work on the original string.
To do that, the string parameter needs the "Make a local copy of the value" to be un-ticked.

- string_copy.jpg (57.37 KiB) Viewed 7069 times
In order to debug this issue I simplified the Replace macro, which might be of value to you, so I have attached my version.
If you run this simulation, with the box ticked and un-ticked and compare what happens with the "test" and "result" strings you will see the issue.
Regards,
Leigh
Re: Macro return string longer than 20 characters
Posted: Thu Aug 17, 2017 11:47 am
by tiny
Thank you, now I understand it! I have created an additional input, declare it as not a local copy, and pass the result at the end of this input string. This keeps the original string unchanged and it also works with the simulation.
Christina
Re: [Solved] Macro return string longer than 20 characters
Posted: Thu Aug 17, 2017 11:50 am
by LeighM
Sounds good

Re: [Not Solved] Macro return string longer than 20 characte
Posted: Mon Aug 21, 2017 12:44 pm
by streammaster
Hi Leigh,
I followed the example which you provided (which is not working on my Flowcode 7: the result is only 20 characters regardless ticked box as you suggested in workaround bellow.
The Flowcode which i'm running is a pro version V7.2.14 (Mar 31 2017)
I also tried to make a test application to further simplified it.
Could you please help me with resolving this bug? At this stage i'm trying the simulation only.
Regards,
Igor
Re: [Solved] Macro return string longer than 20 characters
Posted: Mon Aug 21, 2017 12:58 pm
by LeighM
Hi Igor,
Try the attached, which has the work around suggested by tiny.
Regards,
Leigh
Re: [Solved] Macro return string longer than 20 characters
Posted: Tue Aug 22, 2017 2:07 am
by streammaster
Thanks for this, but this is using a global variable. Unfortunately this is stopping of using the function call like this (which can be called also by interrupt)::
s_processed = some_other_string_variable + Process_my_text ("input string") +"some other string"
If i have a interrupt calls i'm not sure if the global variable would have return content of actual loop or, or by process called by interrupt? Apart having different global for each (same) function segment call what would make whole thing not efficient with so many declared (and reserved) variables. Is there any way that you can do to fix the 20 character limitation and have actual component how suppose to be? Either allow to be defined in return declaration like Return[50] or so it inherit the property of local string variable:
.local_return[50]
Return=.local_return
Regards,
Igor
Re: [Solved] Macro return string longer than 20 characters
Posted: Tue Aug 22, 2017 9:26 am
by LeighM
Hi,
Yes, you are right, it's a bug that needs fixing.
Although string concatenation does have a few other quirks, so it is best to do things in steps.
Also the output variable does not have to be global.
So you could try something like this...
Code: Select all
s_processed = some_other_string_variable
Process_my_text ("input string", s_processed )
s_processed = s_processed + "some other string"