Got my Lemur app about a week ago and am diving headfirst into scripting. Most of my programming experience is with javascript, so I want to make my scripting more object oriented. One of the first things I noticed is the cumbersome way to get and set object attributes. Fortunately it wasn't too difficult to fix this. With a little scripting I can do this:
setattribute(MultiSlider, 'nbr', 16);
x = getattribute(Multislider, 'nbr');
I was thinking of making custom modules for all the objects and their attributes. Before I start, has anyone already done this and wouldn't mind sharing their work? If not, would anyone else find it useful?
I think you found a good method. I am using both, but still not sure when to use which. Sometimes you can use the '=', sometimes you have to use the set/getattribute().
One year of experience (me), and still unsure about fundamental things.
Yes you can make attibutes act like variables - I do similar stuff sometimes with modules to expose vars at a higher level . . .
Though, I would suggest learning a bit more about Lemur scripting before over-riding basic syntax - you may find issues with your approach later on. . .
Dot.notation applies to variables - get/setattribute applies to attributes . . .
Macciza wrote:
Though, I would suggest learning a bit more about Lemur scripting before over-riding basic syntax - you may find issues with your approach later on. . .
MM
MM, can you think of any possible issues to be aware of? Aside from the tedium of implementing it? The big problem I see is changing an attribute directly after the referencing expression is initialized. I think that should easily be avoided if I'm not careless, but I might be overlooking something due to my lack of experience. I can see the possibility of painting myself into a corner. I guess it's safest to start off small and see how that goes.
Hi
Hard to say without seeing what you're doing . ..
But there will be bloat if you add it to everything and use a lot of objects etc
It may may it difficult to understand standard Lemur programming as you wont have learnt it . .
Others may find your Projects difficult to understand or use bits of due to your over-riding . . .
Somethings that are standard practice may give unexpected results
Send in an example of how you might approach it
And run comprehensive tests to evaluate that things do work . . .
Usually attributes are not used as much or in the same way as object variables so it is hard to say how much actual advantage you may gain
I can see that it nmay be handy in certain instances but feel it is probably best on a per case basis for certain attributes of certain objects rather than open slather . . .