Translate M4L patch to javascript - retrieve track number

kmll's icon

I need to get the value of which track number the device is on in javascript. I found the example below and it works fine but I need to do the same inside javascript. I have tested a few ways but I can't figure out how to translate on my own. Please advise if you know:)

Max Patch
Copy patch and select New From Clipboard in Max.
moss's icon

If you have the JavaScript device object it has an attribute "unquotedpath" which you can split to get the track number:

var parts = device.unquotedpath.split (' ');
var trackNo = Number (parts[2]);

Example to get the device:
var device = new LiveAPI ('live_set view selected_track view selected_device');

If you just have a device ID, you can do:

var api = new LiveAPI ();
api.id = Number (deviceID);
var parts = apiunquotedpath.split (' ');

kmll's icon

Thank you for the advise but I still did not get it to work. How can I retrieve the deviceID?

moss's icon

This should do it:

var api = new LiveAPI ('this_device');
var parts = api.unquotedpath.split (' ');
var trackNo = Number (parts[2]);

kmll's icon

Brillian:) Thanks!

zzzeddartha's icon

Hey Moss,

How did you figure out that "unquotedpath" was even an available attribute? If I could just find documentation on what methods/attributes are available via LiveAPI, I could use it!