Forums > Javascript

How do I pass array-type arguments to Live API in JS?

July 9, 2010 | 2:00 pm

I’m desperately trying to enable/restore stop clip buttons on APC40 with JS LiveAPI:

[code]
...blabla...
api.call("set_stop_track_clip_buttons", ???????????);
[/code]

Python implementation expects an array of button instances, so in Max/JS we can assume this function to expect something like a list of control id’s or a list of "id X"-type strings.. any ideas? So far anything I try leads to "invalid syntax" :/

Python definition, SessionComponent.pyc:

[code]
def set_stop_track_clip_buttons(self, buttons):
assert ((buttons == None) or (isinstance(buttons, tuple) and (len(buttons) == self._num_tracks)))
if (self._stop_track_clip_buttons != buttons):
if (self._stop_track_clip_buttons != None):
for button in self._stop_track_clip_buttons:
button.remove_value_listener(self._stop_track_value)

self._stop_track_clip_buttons = buttons
if (self._stop_track_clip_buttons != None):
for button in self._stop_track_clip_buttons:
assert isinstance(button, ButtonElement)
button.add_value_listener(self._stop_track_value, identify_sender=True)
self._on_fired_slot_index_changed(list(buttons).index(button))

self._rebuild_callback()
self.update()
[/code]


July 24, 2010 | 5:45 pm

I have the same problem in trying to call the "note" method, which expects a list of 5 numbers after it.

seeing that with other methods which don’t require arguments the syntax is like this:

clip.call("select_all_notes");

i’m not sure what we’re supposed to do when there ARE arguments.
The

the docs say:
The documentation says:

——
call (function(arguments…))
Calls the given function of the current object, optionally with a list of arguments.
——

but if the arguments to the "call" method are provided as a string (like the "select_all_notes" example above), then what to do when there are arguments?

Here are various failed attempts:

code:
myClip.call("note",64, 0 , 0.25, 100 , 0);

error in max window:
jsliveapi: Invalid syntax: ‘note 64 0 0.25 100 0′

code:
myClip.call("note","64 0 0.25 100 0");

error in max window:
jsliveapi: Invalid syntax: ‘note "64 0 0.25 100 0"‘

code:
myClip.call("note(64, 0, 0.25, 100, 0)");

error in max window:
jsliveapi: ‘Clip’ object has no attribute ‘note(64, 0, 0.25, 100, 0)’


Viewing 2 posts - 1 through 2 (of 2 total)