Forums > Javascript

@-style attributes in js…

May 02 2008 | 4:20 pm

just wanted to confirm…it’s still not possible to use @-style attributes in javascript in max 5? (or, has it been possible all along, and i just didn’t know it?)


May 04 2008 | 10:59 am

In 4.6, I just parse them using some prewritten code.

Basically, I create the variable and default value, and add its name to an array of valid attribute names. Then I parse jsarguments for properly-formed pairs which match the format @ATTR1 VALUE (checking for the presence of ATTR1 in the atribute array). Finally I use an eval to set the value of a variable corresponding to the attribute name (ATTR=VALUE).
My parser also handles position-dependent arguments.
Apart from the code used to do the parsing etc (which isnt particularly optimised, so about 60 lines long), which could be included in a code template, that reduces my argument and attribute parsing to the following:

args = new argHandler;
// note – declare arguments in order;
var ARG1 = 100;
var ARG2 = 0;
var ATTR1 = 100;
// required : reads and evals supplied arguments
// posts all attributes as per a non-js patcher

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

Forums > Javascript