Extract char from text by index?

Extract char from text by index?

  

Hello,

I was trying to write an expression (P10, server action):

If(InputStructure.TextValue[0] = "/", this(), that())

What surprised me was the message "'Boolean' data type required instead of 'None'.

Am I really not able to get single char value out from text/string just by index?

Yes, I can work around this with builtin Substr() action, just asking.

If(Substr(InputStructure.TextValue, 0, 1) = "/", this(), that())


Hi Mikko,

Your "workaround" is not a workaround in OutSystems, it is the way to do it.

You cannot access each character in a a string as a character array as far as I know.

Regards,

Daniel.

Solution

Hi Mikko,

Correct. Your "InputStructure.TextValue" type is a text. You can only get the char, in a position of text, using "Substr()" method.

Regards,

Solution