Skip to main content
MiladChalipa
Associate III
March 15, 2021
Solved

Simple code to compare TextArea Wildcard with a constant character and make a decision (TouchGFX)

  • March 15, 2021
  • 1 reply
  • 836 views

Hello

I have a TextArea Wildcard in my display that shows "ON" or "OFF" when the screen entered and has a FlexButton in front of it. when FlexButton clicked, I want to change the current State. To do that (I believe) have to get the wildcard value and compare it with the constant "ON", then change the wildcard value in the IF statement. So what is a straight way to do that?

This topic has been closed for replies.
Best answer by Alexandre RENOUX

Hello MiladChalipa,

When it comes to comparing states, using a Boolean is more common and easier to code. Simply create a Boolean variable that switches from true to false accordingly and perform your action (here changing the textArea content) according to the current state/ value of the Boolean.

But for your information here is one way to compare the content of a TextArea :

Unicode::UnicodeChar tmp[2] = {'O','N'};
if(Unicode::strncmp(tmp, textArea1.getWildcard(), 2) == 0)
{
 touchgfx_printf("equal\n");
}

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

1 reply

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
March 16, 2021

Hello MiladChalipa,

When it comes to comparing states, using a Boolean is more common and easier to code. Simply create a Boolean variable that switches from true to false accordingly and perform your action (here changing the textArea content) according to the current state/ value of the Boolean.

But for your information here is one way to compare the content of a TextArea :

Unicode::UnicodeChar tmp[2] = {'O','N'};
if(Unicode::strncmp(tmp, textArea1.getWildcard(), 2) == 0)
{
 touchgfx_printf("equal\n");
}

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre