string comparison?
On Jun 10, 2008, at 8:44 AM, Diemo Schwarz wrote:
> it should be obvious, but I didn't find a way to test two non-
> constant symbols for equality in max!?
The Jasch objects contain many string operators including strcmp.
-C
Chris Muir
cbm@well.com
http://www.xfade.com
a hack way could be with atoi, then find a way to compare the numerical values. Would be simple if they are single characters, trickier if they are words (so become lists of #s). These might be easier to work with using match (?) not sure. At least they're then numbers.
mxj likely has plenty to do this, if you want to do a little Java. But that seems like extra effort when there are those other options as mentioned here---jasch has tons of stuff for strings, not to mention a lot of other very useful objects.
--CJ
I use atoi in a few special cases, like checking an index number at the end of a string. But otherwise, i use jasch's strcmp. It's fine, only thing i'd like it to have is a right inlet.
atoi -> zl ecils 4 -> itoa -> strcmp for extension comparison.
Diemo Schwarz schrieb:
> it should be obvious, but I didn't find a way to test two non-constant
> symbols for equality in max!?
I had a St.change abhaXion based on match for a long time in my St.ools
collection, but found a better way in the mean time:
(There is a "===" and a "St.Change" embedded which could be saved
seperately...)
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
Cool solution, St!
Can't be arsed to build it into my patch in various places, but I like avoiding externals when possible, so I could use this in the future...
Hi Stefan
Need to do the same thing but I can't see how this works. I expected to see two inlets for the two strings but there is only one. Could you leave a line or two explaining how this works?
Thanks in advance.
a+
gar
Here are two versions that compare symbols in max 4. One is similar to [change] and the other to [==]. I hope they help.
lh
Hi thereishopeforus@hotmail.com
Thanks for this, works well, got sidetracked for a few days, sorry for being slow to respond.
a+
gar
there is also the jit.str.op object which has some interesting features ( if jitter is an option )
Quote: Diemo Schwarz wrote on Tue, 10 June 2008 17:44
----------------------------------------------------
>
> Hi,
>
> it should be obvious, but I didn't find a way to test two non-constant symbols
> for equality in max!?
>
> � [==] only works on numbers
> � [route] only compares a symbol with a fixed symbol
> � [select] loses its second inlet to set the comparand as soon as you put a
> symbol in its args
> � the help of the [if] object mentions $s1, but then tells me: bad expression
> $s1 == $s2
>
> what I actually want is a [change] object for symbols...
>
> I'd be grateful for any hints. Cheers...
> ...Diemo
>
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
----------------------------------------------------