Using fromsymbol but keeping zero padding?

    Apr 05 2014 | 9:29 am
    I've got a bit of javascript code that is spitting out strings that I want to pack into a coll. What's coming out of js is:
    "1 0011" "2 1011" "3 0001"
    Coll isn't happy with them as is, but if I run them through fromsymbol I get:
    1 11 2 1011 3 1
    which is a problem.
    The thing is the length of the string is dynamic (depending on what I feed javascript), so I can't just have a single sprintf formatting it.
    How does one convert a string of arbitrary length to a normal message while keeping the zero padding intact?

    • Apr 05 2014 | 9:47 am
      If you want zero padding, then you need symbols. Period.
      Numbers are *values* and they are simply represented in an arbitrary display format that happens to be decimal (rather than binary or octal or hex or something else) and happens to trim unneeded zeros left and right.
      You could use regexp to split the strings into an int followed by a symbol, but if it's your JScript code, why don't you just have the object give you what you need? Something like outlet(0, index, stringvalue).
    • Apr 05 2014 | 10:24 am
      The problem was I was packing the index into the string itself before spitting it out. I just changed it to add the index when spitting out and it works!
      for (var i = 0; i < combinations.length; i++) { outlet(0, i, combinations[i]); }
    • Apr 05 2014 | 10:30 am
      This also works...
    • Apr 05 2014 | 2:13 pm
      Ok, this is working to get it into coll, but it looks like I can't iterate it once it comes out of coll as it's still a single symbol.
      I want to be able to convert the coll contents into a matrixctrl (which then controls a USB-MIDI relay thing).
      This is what seems like it would work, but doesn't because of the symbol-ness of coll's contents.
    • Apr 05 2014 | 4:02 pm
      I figured I out. I converted the string from "0011" to "0 0 1 1" in js then [fromsymbol] does the trick in Max.
    • Apr 05 2014 | 7:49 pm
      Couldn't get that last one to work.
      Here's another way from a bit symbol to matrixcrl.
    • Apr 05 2014 | 7:52 pm
      Ah nice!
      More elegant than my solution anyways.
    • Apr 06 2014 | 2:58 am
      hmm.. that zl.join is completely useless. Not sure why it's there. Remove at leisure. :)