Check char value of string at specific index


#1

Hi all,
I have a repeater object and am trying to find a work around to change the text color of a repeater item - BASED on a specific value of the SECOND character in the string (index position 1) being “L” . I am putting the check on the load event on the individual item inside the repeater.
Basically, I want to add a condition that checks that second character for each item and then uses the setText - to rich text that I basically put the same repeater item and just change the text color. What I am having trouble figuring out is how to set up the statement in the condition builder fx panel.

In the condition builder, I have created a local variable that contains the text on my repeater item, and am unsure about the next part,
so far:
if text on This contains “[[LVAR.charAt(1) == (L)]]”

I don’t think I’ve got this statement quite right, any pointers would be much appreciated!


#2

Hi!

Try this:

If (value) [[LVAR.charAt(1)]] equals L

Visual:

… where LVAR refers to the text of something. By the way, you seem familiar with them, but here is a helpful post about local variables.


#3

Hi @tishaleggett,

Are you setting the text from one of your repeater columns? If so, you could also set up a conditional case in the repeater’s OnItemLoad event, to check and see if the second character in the column == ‘L’.

The statement would be: If [[Item.Column0.charAt(1) == (‘L’)]] equals true, and then you could set the text to red.

In the OnItemLoad event… the first case sets the text to Rich Text with a red color, the second case (Else if true) sets it to the normal text color:

Here’s the sample file: red.rp (50.2 KB)


#4

This worked perfectly, much simpler than what I was trying to do. It also supports multiple conditions nicely. Thank you very much!!


#5

Thanks so much for the help! I tried using the value condition vs text on widget condition, I had an array of 25 two digit values that I needed to check the second character value and color it differently depending on what condition it met - The suggestion offered above seemed to handle this perfectly.