cancel
Showing results for 
Search instead for 
Did you mean: 

Pass string to a function

ALuiz.1
Associate II

I need to pass a 6 characters string to a function in a custom container, but the string is cut to 4 characters.

The function is called in the screen where the container is, like this: container.function(str). 

If I pass a string smaller than 5 characters it works ok, but greater not. I'm sure at this moment the 6 characters string is complete.

In the custom container the string and the function are defined as follows:

 Unicode::UnicodeChar str[7];

 function (Unicode::unicodechar * str);

Is there a limitation to pass strings greater than 4 characters in TouchGFX? How could I solve it?

Thanks.

2 REPLIES 2
Osman SOYKURT
ST Employee

Hello ALuiz.1,

I've tested to show logs with a function in a container with a string given by my main screen. I don't reproduce the error you describe. You'll find attached an example of how I get a string with my container.

Do want to use it on a text Area in your container? If yes, what did you put as your buffer size in your wildcard ?

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

Thanks for the answer.

I solved the problem changing the type of the variable passed.

In screen I created an uint8_t buffer and I used the commands:

Unicode::toUTF8(str, buffer, 7);
container.function((char *)buffer);

In custom container I did:

function(char * str)
{
    Unicode::fromUTF8((uint8_t *)str, localBuffer, 7);
   ...
}