Custom symbol: How to compare strings in conditional test?

I’m trying to compare some strings for some custom symbol in a conditional test. Unfortunately I don’t get it to work.

 179  0  A CWT C
-170  15 A CNT B
-160  0  D CET C
-170 -15 A CST C

I need to test the third, fourth and fifth column.

When looking at 18.2.6 Text Substitution in the CookBook I find:

However, you can also obtain the entire string from your input file via a single symbol variable $t that must be declared with type s (string). The string will be taken as all trialing text in your data record. To select a single word from the trailing text you just use $tk , where k starts at 0 for the first word, regardless of how many numerical columns that precede it.

In my understanding this means $t = A CWT C for the first entry and I can access it the following way:

$t0 = A
$t1 = CWT
$t2 = C

When I look in 18.2.8 Conditional statements string comparison is possible:

For text comparison note that case will be considered, so “A” does not equal “a”.

My bare bones custom symbol is

N: 1 s

if $t0 == A then {
  0 0 1 c -W2p,red
} else {
  0 0 1 c -W2p,green
}

but all I get is an error message instead of three red rings and a green one.

plot [ERROR]: Unrecognized symbol code (123 = '{') passed to gmt_draw_custom_symbol

I’m sure I’m making a mistake somewhere. And I haven’t even started to compare for $t1 … Would you kindly nudge me in the right direction? Thank you!

The script to play along:

#!/usr/bin/env bash

cat > location.txt  << EOF
 179  0  A CWT C
-170  15 A CNT B
-160  0  D CET C
-170 -15 A CST C
EOF

cat > ifelse.def << EOF
N: 1 s

if $t0 == A then {
 0 0 1 c -W2p,red
} else {
 0 0 1 c -W2p,green
}
EOF

gmt begin if_else pdf
  gmt coast -R0/360/-70/70 -JM17c -BWESN -Bxa40f20 -Bya20f20 -Dc -A5000 -Saliceblue -W0.75p,grey
  gmt plot location.txt -Skifelse/1c
gmt end show

Should be fixed in https://github.com/GenericMappingTools/gmt/pull/4643.

Oh, I wasn’t aware that this was never intended to work. Now it works like a charm! Thank you very much for the very quick implementation, @pwessel!