How to test for string equality
dtadams
I was trying to write a function that took in the name of an axis (eg "x") and generated a rotation matrix about that axis. However, I could not find any function to test if two strings were equal. It seems like this should be a fundamental part of any programming language (even one whose emphasis is on analysis).
I've check the manual and the "command help" window and found nothing. How do you test strings for equality in Igor?
July 1, 2014 at 02:11 pm - Permalink
July 1, 2014 at 03:46 pm - Permalink
Only if you don't have "*" in your strings, and they don't start with "!".
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 1, 2014 at 05:03 pm - Permalink
Thanks!
(I feel like this should really be included in the part of the manual dedicated to Strings though -- vol. 4, chapter 1 in the section called "Strings". That seemed like the natural place to look...)
July 2, 2014 at 08:15 am - Permalink
Yes, that should be covered somewhere in that small section.
Depending on your application, you may also be interested in the strswitch command:
strswitch( eventNameStr )
case "killVote":
TitleBox warning win=$s.winName, title="Press the Done button!"
Beep
statusCode=2 // prevent panel from being killed.
break
case "mousemoved": // to reset the warning
TitleBox warning win=$s.winName, title=""
break
endswitch
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
July 2, 2014 at 09:29 am - Permalink