Using fromsymbol but keeping zero padding?
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"
etc...
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?
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)
.
Perfect!
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]);
}
This also works...
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.
I figured I out. I converted the string from "0011" to "0 0 1 1" in js then [fromsymbol] does the trick in Max.
Couldn't get that last one to work.
Here's another way from a bit symbol to matrixcrl.
Ah nice!
More elegant than my solution anyways.
hmm.. that zl.join is completely useless. Not sure why it's there. Remove at leisure. :)