element enumeration bug?

Questions, tips and tricks and techniques for scripting in Servoy

element enumeration bug?

Postby david » Fri May 23, 2003 4:09 am

This works: elements.element_name.bgcolor = '#CCDDAA';

This does not work: elements[0].bgcolor = '#CCDDAA';

I get the impression from the manual that something like this is doable. Is it a bug at the moment or am I doing something wrong?

- david
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Postby maarten » Sun May 25, 2003 11:31 pm

It's indeed a bug :(

dev team is solving this.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby maarten » Mon May 26, 2003 12:26 pm

Since this can be a HUGE timesaver writing code, here's a script example for all readers to clarify this subject a bit.
(BTW I tested this code with build 257, and it should work)

Assume you have a form with 2 textfields and 8 scriptbuttons that can set both the textfields along with some generic code.
(it's a bit hypothetical, but the concept applies to many other situations)
Scripts would look like this:
script1
1)...show dialog
2)...do a lot of checks
3)textfield1 = "button1Click setting textfield1"
4)textfield2 = "button1Click setting textfield2"

script2
1)...show dialog
2)...do a lot of checks
3)textfield1 = "button2Click setting textfield1"
4)textfield2 = "button2Click setting textfield2"

etc, etc....

This is NOT what you want, if you have to change something in the generic code. (changing dialogtext, would have to be done in 8 different scripts. Extra annoying, knowing that it's 8 times the same change you have to do.)

So...given the situation, here's the way you would want to go:

Make one generic script that looks like this:

genericScript
var textField1Content = arguments[0]
var textField2Content = arguments[1]
1)...show dialog
2)...do a lot of checks
3) textfield1 = textField1Content
4) textfield2 = textField2Content


...the other 8 scripts would look like this:

script1
1) genericScript("button1Click setting textfield1", "button1Click setting textfield2");
// calls the subscript "genericScript" and pushes the arguments to the genericScript 8)

script2
1) genericScript("button2Click setting textfield1", "button2Click setting textfield2");

etc,etc...

diabolic :twisted: :wink:
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 8 guests