IF command with strings

Hello everybody...

I would like to know how to use the IF command to check string variables, to do something like this:



string Svar

IF ( Svar=="ABC" )
      // do this
Else
     // do that
EndIf


I know it is a silly question, and should have a simple solution.. but I've been stuck with this for a long while, and I have found just examples with numeric variables.

Thanks

Andre
ChrLie
you need


string str
if (cmpstr(str, "ABC") == 0)
  //do this
else
   //do this
endif


I would not use "svar" as string name, because SVAR is used as global string declaration.
jtigor
Also consider
stringmatch
for this use. The help page for stringmatch lists a few other useful string handling functions.
jjweimer
An alternative construction is illustrated here.


Function TestString(tstr)
     string tstr

     strswitch(tstr)
          case "Hello":
              print "got hello"
              break
          case "Goodbye":
              print "ciao"
              break
          default:
              print "Input Hello or Goodbye only"
              break
     endswitch
     return 0
end



--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
jcor
Another nice function for this is
GrepString
,
which would allow you to match all of "abc1", "abc2", "abc3" using "abc"
(or even "abc\d{1}")