Javascript access to "---"

Learn about building and using Max for Live devices.
Post Reply
Surreal
Posts: 560
Joined: Wed May 17, 2006 1:18 am

Javascript access to "---"

Post by Surreal » Sat Feb 06, 2010 8:15 pm

How do i figure out the patchers --- number in a js file?

emmanuel_2
Posts: 127
Joined: Fri Sep 11, 2009 7:54 am
Location: Paris
Contact:

Re: Javascript access to "---"

Post by emmanuel_2 » Sun Feb 07, 2010 1:32 am

Surreal wrote:How do i figure out the patchers --- number in a js file?
The easiest way is to put something as argument to your js object, like "js yourawesomejsfile.js ---randomstuff". Then in your global code you can access to the argument of your js object (using jsarguments[1]) and then parse that string to get the number before randomstuff.
ej

Surreal
Posts: 560
Joined: Wed May 17, 2006 1:18 am

Re: Javascript access to "---"

Post by Surreal » Sun Feb 07, 2010 3:13 am

that ... didn't (seem to) work...but now that i think about it again, i think i know why.

when i open a patch in edit mode, that number is not generated.

thank you.

emmanuel_2
Posts: 127
Joined: Fri Sep 11, 2009 7:54 am
Location: Paris
Contact:

Re: Javascript access to "---"

Post by emmanuel_2 » Sun Feb 07, 2010 11:43 pm

Surreal wrote:that ... didn't (seem to) work...but now that i think about it again, i think i know why.

when i open a patch in edit mode, that number is not generated.
Yeah that must be it. Doing something like that seems to work fine:

Code: Select all

var id;

function findId()
{
    var str = jsarguments[1];

    id = str.replace(/(.+)randomtext/, "$1");
    post(id);
}

findId();
ej

Post Reply