Character comparison

Hello,
will I be able make similiar program like I done in C++ ?

int main(){
string word = “car”;

for(int i = 0; i < word.length(); i++) {
char x = word[i];

switch(x){
case ‘c’:
GOTO Path_10
break;
case ‘a’:
GOTO Path_20
break;
case ‘r’:
GOTO Path_30
break;
}
}
}

Problem is that I don’t know how should I comparison character in string in robotstudio. I try command TEST but there I can only comparison number.

Thanks for help.

PERS string test_txt:=“up”;

PROC main()

TEST test_txt

CASE “up”:

TPWrite “up”;

CASE “down”:

TPWrite “down”;

DEFAULT:

TPWrite “other”;

ENDTEST

ENDPROC

Use the string functions to manipulate your text and extract individual letters (see attached).
String functions.pdf (425 KB)

Thank you


  PROC main()

    VAR string x;

    VAR string word := "car";

    VAR num counter := 1;

    

    ! loop all chars

    WHILE counter <= StrLen(word) DO

      

      ! get char

      x := StrPart(word, counter, 1);

      

      ! switch based on char

      TEST x

      CASE "c": GOTO Path_10;

      CASE "a": GOTO Path_20;

      CASE "r": GOTO Path_30;

      ENDTEST

      

    ENDWHILE

    

    ! dummy labels

    Path_10:

    Path_20:

    Path_30:

  ENDPROC

I already solve my problem but thank you !