|
Passing keyed structures between JavaScript nodesI'm having a heck of a time trying to figure out how to work with keyed structures that are passed between JavaScript patches. For instance, in the first JavaScript patch, I have this... function (__structure outputStructure) main () { var result = new Object(); result.outputStructure = new Object(); var myStructure = new Object(); myStructure.something = new Object(); myStructure.something.amazing = new Object(); myStructure.something.amazing.here = "yes"; result.outputStructure = myStructure; return result; } outputStructure is then connected to myStructure of JavaScript patch number two... function (__string somethingamazing) main (__structure theStructure) { var result = new Object(); result.somethingamazing = theStructure.something.amazing.here; return result; } I expect somethingamazing to return "yes", but instead I am left with a persistent error:
I originally encountered this problem when I was attempting to make use of the structure output from the MIDITools plugin, so I suppose the problem doesn't have to do specifically with passing keyed structures between JavaScript patches, but that I'm simply doing something wrong with trying to get the structure into JavaScript. I feel, as I so often do, that I am missing something extremely obvious. Can anyone shed some light on my mistake?
|
The first time a Javascript patch is evaluated, it's run in "Test Mode". At this time, the structure inputs are null, so you won't be able to dereference them.
You can work around this by either testing to make sure the structure input is not null, or by checking the value of the
_testMode
global constant.Thanks, this solved the problem!