using multiple #1 symbol arguments to pass multiple arguments to abstraction

    Aug 01 2011 | 11:51 pm
    Hi all,
    I'm trying to send an abstraction two arguments and I'm having trouble figuring out how to do this.
    In Pd, inside an absraction I would put a [receive $1_$2_envsize] and then one level up I would give that abstraction object two arguments, say "table1" and "5". then if I sent a message to [send table1_5_envsize] the receive within that abstraction would receive the value.
    In Max, this doesn't work. it will only allow one symbol argument, e.g. #1_envsize. but it won't recognize a second #2 after the #1, e.g. #1_#2_envsize.
    Does anyone know how to get something like this working?
    Many thanks!

    • Aug 01 2011 | 11:54 pm
      AHH! I instantly figure it out.
      In Max, you have to separate the #1 #2 with a space. So in relation to the Pd example I gave above, #1 #2_envsize would work.
    • Aug 02 2011 | 2:29 am
      I believe that any #1 or #2 etc. also needs to be at the beginning of the symbol you're using, if you're using a name/symbol. so [send #1_my_value] works (you can replace the #1 with an argument), but [send my_#1_value] won't. however, you can do more exact substitution trickery with [sprintf].
    • Aug 02 2011 | 3:07 am
      Yeah I was mistaken on my fix..
      Wow this is killing me! Pd is sooo much better in certain areas - this is one of them.
      So if I would like to specify two unique arguments to be passed to an abstraction, I can use sprintf? How would I do that?
      Many thanks!
    • Aug 03 2011 | 1:20 am
      ok I think I was wrong, just use #1 #2 #3 #4 etc. for multiple arguments in the abstraction, keeping the #1 #2 etc. at the front of symbols (if you use symbols at all). [sprintf] is for formatting messages/symbols and lets you insert elements right into symbols regardless of spaces, which the standard message box won't allow. I tried
      [sprintf #1_my_msg my_#2_msg]
      in an abstraction with the arguments 4 and 66, and got
      [sprintf 4_my_msg my_#2_msg]
      as the result, so again, it didn't substitute the #2 when it was within a symbol.
    • Aug 03 2011 | 1:42 am
      "In Max, you have to separate the #1 #2 with a space. So in relation to the Pd example I gave above, #1 #2_envsize would work."
      yes, but that would end up as list "100 200_envsize" and that might be not what you want. so in case you really need to include 2 arguments-to-patcher in a symbol, you have to format the symbol after you received the args. p.s. re:sprintf: thats the way to go. in the above example you would just concatenate two symbols into one: [loadbang] [t #1_]   [t #2_envsize] [zl join] [sprintf %s%s]
      which, btw, would make another nice abstraction itself, if you need that regulary. i dont have maxmsp here now ... i think you can also use the right inlet instead of zl join.
    • Aug 03 2011 | 1:48 pm
      yep, the right inlet of [sprintf] would be fine, just make sure it gets there before the left ("hot") inlet, which sends out the whole symbol.
      Makes sense about the [sprintf], good clarification.