Radio boxes have the attribute this.number to see how many entries they have, but I can't find any corresponding attribute to find out how many boxes a check box object has.
Is this information not available to the panel scripts?
Number of boxes in a check box object
- dbindernagel
- Posts:161
- Joined: Mon Feb 23, 2015 1:34 pm
Re: Number of boxes in a check box object
The property "number" on a radio box control returns the index of the active radio box (starting with 0) and not the total count of radio boxes in the control.
(The check box control doesn't have a number property since multiple check boxes can be active at the same time.)
(The check box control doesn't have a number property since multiple check boxes can be active at the same time.)
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Number of boxes in a check box object
OK, you are right about that.
But luck has it that in the init script of a radio button object the value of this.number is always set to the number of buttons. An undocumented feature, I guess.
At least the radio button and check box objects are consistent then, but it would sure be helpful to me if the scripts could find out how many elements those objects have.
Is there any proper way to get at that information?
But luck has it that in the init script of a radio button object the value of this.number is always set to the number of buttons. An undocumented feature, I guess.
At least the radio button and check box objects are consistent then, but it would sure be helpful to me if the scripts could find out how many elements those objects have.
Is there any proper way to get at that information?
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Number of boxes in a check box object
You're wrong. this.number returns the checked button, which can be something else than the last one. You can check one in the editor in Gedi.
There is currently no way to get the number from a script, but since you can also not change the number via script, what would be the use case ?
There is currently no way to get the number from a script, but since you can also not change the number via script, what would be the use case ?
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Number of boxes in a check box object
This is the code that I have in the init script
to automatically translate the texts to foreign languages and it works!
Of course I have to do this before someone gets the chance to click on one of the buttons, which will change the value of this.number.
I also realize that this is an undocumented feature, that may not work in a future version.
Still I would welcome the addition of such an attribute to the radio and check box functions in a future version, similar to the attributes registerCount and itemCount that other objects have.
There I do the translation of the register headers and items in a similar way.
For the check boxes I have to manually pass the number of boxes, which works too but is not so elegant.
Code: Select all
main()
{
for(int i = 0; i < this.number; i++)
{
this.text(i) = bms_Tools_TagText(this.text(i));
}
}Of course I have to do this before someone gets the chance to click on one of the buttons, which will change the value of this.number.
I also realize that this is an undocumented feature, that may not work in a future version.
Still I would welcome the addition of such an attribute to the radio and check box functions in a future version, similar to the attributes registerCount and itemCount that other objects have.
There I do the translation of the register headers and items in a similar way.
For the check boxes I have to manually pass the number of boxes, which works too but is not so elegant.
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Number of boxes in a check box object
Why do you need this at all ?
The texts of the items are already stored in translatable format (multi languages) inside the panel file.
The texts of the items are already stored in translatable format (multi languages) inside the panel file.
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Number of boxes in a check box object
The problem with the way the panel translation works is that each combination of words needs to exit in a cat file which makes for a very long list which we currently have to translate into 10(!) languages.
For primitive phrases with low demands on grammatical correctness we have found that translating word by word base on 3 letter tags is more efficient.
For example, our dictionary looks like this:
Tag English German
----- ----------- ----------
Clg Cooling Kühlung
Htg Heating Heizung
Pum Pump Pumpe
Lef Left Links
Rit Right Rechts
so in the Gedi we enter phrases like the following:
@HtgPum
@HtgPumLef
@HtgPumRit
@ClgPumLef
@ClgPumRit
which our function bms_Tools_TagText() (see my previous note then translates into the active language when the panel is opened.
This allows us to very quickly and easily add phrases to our panels, as long as we can build them from our basic tag vocabulary, without having to have each one translated into each language.
If you understand this, then you may now also better understand the reason for my service request 1-4220912636
For some objedts, like buttons, the text is a langString so that I can always pass the text from our main language (English) to our function.
But for other objects like checkboxes or radio buttons the text is only a string (even though there is an entry for each language if I look at the panel file with a text editor) so I need to copy the above phrases into all language entries, because I have no access to the main language text when another language is active.
For primitive phrases with low demands on grammatical correctness we have found that translating word by word base on 3 letter tags is more efficient.
For example, our dictionary looks like this:
Tag English German
----- ----------- ----------
Clg Cooling Kühlung
Htg Heating Heizung
Pum Pump Pumpe
Lef Left Links
Rit Right Rechts
so in the Gedi we enter phrases like the following:
@HtgPum
@HtgPumLef
@HtgPumRit
@ClgPumLef
@ClgPumRit
which our function bms_Tools_TagText() (see my previous note then translates into the active language when the panel is opened.
This allows us to very quickly and easily add phrases to our panels, as long as we can build them from our basic tag vocabulary, without having to have each one translated into each language.
If you understand this, then you may now also better understand the reason for my service request 1-4220912636
For some objedts, like buttons, the text is a langString so that I can always pass the text from our main language (English) to our function.
But for other objects like checkboxes or radio buttons the text is only a string (even though there is an entry for each language if I look at the panel file with a text editor) so I need to copy the above phrases into all language entries, because I have no access to the main language text when another language is active.
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Number of boxes in a check box object
Here is another example where it would be handy to know the number of boxes that a checkbox object has.
We connect to an unsigned integer, and set the state of each box to true if the corresponding bit in the integer is set:
We connect to an unsigned integer, and set the state of each box to true if the corresponding bit in the integer is set:
Code: Select all
// work function for bmsPmt_CheckBox_Init() above
// The variable 'number_of_checkboxes' must be declared and initialized in the calling panel
bmsPmt_CheckBox_Work(string dp1, unsigned mode)
{
this.backCol = "_Transparent";
for (int i=0; i < number_of_checkboxes; i++)
this.state(i) = (mode & (1