elements.allnames __anonym1148458008346

In a form I have a button with no name, while all other elements are named (bt_01, bt_02, etc). I wanted to put all named elements in an array to loop through them and set visible = false/true.

But var arr = elements.allnames gave me a strange result with an elemente named __anonym1148458008346 in position 0 of the array. When I loop through the array the unnamed (_anonym…) element was set to visible = false. However this __anonym1148458008346 element did not always appear when performing again var arr = elements.allnames.

Is there any reason for this? I thought that unnamed elements would never appear in the array resulting from elements.allnames

I am using Servoy 2.2.5 on MacOS X 10.4.6.

I have seen the same issue [present since at least 2.0 and probably 1.x] and if you are not aware of and do not screen out the anonymous elements it created difficult to find errors in some methods. Unless these elements have some purpose it would be nice to do away with them.

John McCann
Windows XP
SQL SERVER 2000

I often loop through all named elements looking for something such as tabpanels, etc. The way I have always done it is something like this:

for ( var i = 0 ; i < forms[globals.g_formName].elements.length ; i++ )
    var name = forms[globals.g_formName].elements[i].getName()
}

I find that in this case the ‘length’ property of all the form’s elements is correct (i.e. leaving out the ‘_anon…’ elements). If I put those names from the for loop in an array it just contains those elements I have actually ‘named’. I’m not sure what the reasoning behind having the ‘allnames’ property of elements on a form contain elements that are ‘unnamed’ by the developer. Nor have I figured out exactly what makes an ‘unnamed’ element appear on that list (I certainly don’t think it is every unnamed element). But I can imagine situations where it might be useful. But in any case using the length property of a form’s elements will, I believe, always get you the correct number of named elements and looping through those will allow you to then set any properties just as efficiently as creating an array.

I agree that, if you know there is an “anonymous” element, you can deal with it. But I could not figure out when it appears and when not. I mean, this is the first time I get into an “anonymous” element, however this is not the first time that in a form I mix named and unnammed fields, buttons, labels and so on. Do I have to make a check everytime? And, what’s the ratio behind such a behaviour. I mean, is this a bug or a feature?

Do I have to make a check everytime?

As far as that point goes, no, I don’t think you do ever need to check IF you use ‘forms.formname.elements.length’ to loop and ‘forms.formname.elements*’ to get/set the properties of the individual elements that you NAMED. It is only the ‘allnames’ function that throws up these ‘unnamed’ elements as far as I’ve ever seen.*
> And, what’s the ratio[nale] behind such a behaviour. I mean, is this a bug or a feature?
The answer to those two questions I have no clue :) . I agree it would be good to have some documentation on that one way or the other. I’m haven’t figured out at all what triggers that ‘anon’ element listing using allnames. We’ll have to wait to hear back from the ‘lads’!

It is only the ‘allnames’ function that throws up these ‘unnamed’ elements as far as I’ve ever seen.

You’re right John.
This will be fixed in one of the next build’s.