@-style attributes in js…

May 2, 2008 at 4:20pm

@-style attributes in js…

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?)

Pboer

#37477
May 4, 2008 at 10:59am

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;
args.setUpArgument(“ARG1″);
var ARG2 = 0;
args.setUpArgument(“ARG2″);
var ATTR1 = 100;
args.setUpAttribute(“ATTR1″);
args.argumentParser(jsarguments);
// required : reads and evals supplied arguments
args.reportAttributes();
// posts all attributes as per a non-js patcher

#129559

You must be logged in to reply to this topic.