cancel
Showing results for 
Search instead for 
Did you mean: 

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

MiladChalipa
Senior

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Alexandre RENOUX
Principal

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

View solution in original post

1 REPLY 1
Alexandre RENOUX
Principal

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