![](/profiles/wavemetrics/themes/wavemetrics/logo.png)
Dynamic Strswitch Cases
![](/sites/www.wavemetrics.com/files/styles/thumbnail/public/default_images/Artboard%201_1.png)
Ken
Mon, 06/27/2011 - 02:22 pm
I am wondering if it is possible for a strswitch to have variable cases, such as depending on a text wave's contents. For example, if that text wave (TWave) has elements {A,B,C}, strswitch will return 1 for A, 2 for B, and 3 for C. If the Twave has elements {D,E,F} instead, strswitch will return 1 for D, 2 for E, and 3 for F. I think strconstants may be involved with the process, but don't know how to use them effectively. Below are two of my attempts.
string str
wave/T Twave
strswitch(str)
case TWave[0]:
return 1
case TWave[1]:
return 2
case Twave[2]:
return 3
endswitch
wave/T Twave
strswitch(str)
case TWave[0]:
return 1
case TWave[1]:
return 2
case Twave[2]:
return 3
endswitch
or
string str
wave/T Twave
strconstant case1 = TWave[0], case2 = TWave[1], case3 = TWave[2]
strswitch(str)
case case1:
return 1
case case2:
return 2
case case3:
return 3
endswitch
wave/T Twave
strconstant case1 = TWave[0], case2 = TWave[1], case3 = TWave[2]
strswitch(str)
case case1:
return 1
case case2:
return 2
case case3:
return 3
endswitch
Thank you.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 27, 2011 at 02:26 pm - Permalink
wave/T Twave
variable x
for(x = 0; x < 4; x += 1)
if(cmpstr(str,TWave[x]) == 0)
return (x + 1)
endif
endfor
return (0)
June 27, 2011 at 02:54 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 28, 2011 at 04:47 pm - Permalink