Duplicate control names
Posted: Tue Sep 03, 2013 9:35 am
Hi all.
I've hit a problem and am keen to understand some of the more obscure 'rules' of labeling controls within LC.
Imagine if you will, a card "crd1" with a control "ctrl1" (very original
) on it
I then add a group "grp1" containing a control "ctrl1" (same name as the control on the card BUT, this control is in the group).
99% of the time I can put whatever data I like in whichever control I like simply by adding or omitting 'of group "grp1" ' after specifiying the recipient control
i.e. : set the text of field "ctrl1" to "Card level field"
or : set the text of field "ctrl1" of group "grp1" to "Group level field"
and this works... BUT... recently, on more than one occasion, this has not worked and LC seems to 'mix up' / 'become confused' as to which control I mean to reference with the 'set the text of field "ctrl1" to "Card level field" ' command line.
Like I say, 99% of the time LC understands what I mean simply by my adding / omiting the 'of group...' syntax.
By '99% of the time', it would be more accurate to state that, once LC has decided to reference the group control even though I don't add the 'of group...' syntax, it will then do so forever - each and every time the code line executes. LC does not change its mind once its made up. This is true even following an SDK / computer reboot...
If, I trap the error / insert a breakpoint immediately after the offending line and then message box : 'put the ID of the field "ctrl1"' (note, no ' of group...') I get one ID (764586)
but clicking on the control I get another ID (584239)
then if I message box : 'put the ID of the field "ctrl1" of group "grp1" ' I get the same ID as that without the 'of group...' line (764586)
I guess I've ;
-1- not fully read / understood the nuances of control naming within LC and
-2- gotten away with it for a long time (looks like I may have to go and change quite a lot of code)
-3- I'm unsure as to how LC 'finds'/'matches' the control I'm referencing with my friendly name ( 'ctrl1' ) to its numeric ID (764586). Hadn't given it a thought until now...
Would someone enlighten me on control naming conventions with LC please and how (apart from renaming duplicate control names preferably) I can get around this issue.
Like I say, this occurs only occasionally; sometimes I can 'fix' the issue by creating a new control and then deleting the 'faulty' one... sometimes not - it's a very hard 'bug' / issue to recreate and therefore track down. I'm not sure if copying groups of controls from one card to another is my problem creator or not - sometimes a data entry control set (group) on one card is similar to that on another card, so I've copied, pasted and then modified an existing group from a different card to suit a slightly different (but similar) purpose on a new card. Maybe that's just 'asking' for problems.
Hope someone can kick me in the right direction.
Thanks a million.
<EDIT>
In fact, typing ' put the ID of field "ctrl1" of card "crd1" ' produces the same result (764586) as ' put the ID of field "ctrl1" of group "grp1" ' (764586)
whereas, if I type ' put the ID of field "ctrl2" of card "crd1" ' produces 782419 and a different result for ' put the ID of field "ctrl2" of group "grp1" ' (839126)
To me (a noobie to LC) this is a strange result... in that it does not appear to be repetetive / common...
Someone else must have experienced this and (hopefully) found a (simple/non-destructive) way around it... ? ! ? hopefully
Ideas ?
I've hit a problem and am keen to understand some of the more obscure 'rules' of labeling controls within LC.
Imagine if you will, a card "crd1" with a control "ctrl1" (very original

I then add a group "grp1" containing a control "ctrl1" (same name as the control on the card BUT, this control is in the group).
99% of the time I can put whatever data I like in whichever control I like simply by adding or omitting 'of group "grp1" ' after specifiying the recipient control
i.e. : set the text of field "ctrl1" to "Card level field"
or : set the text of field "ctrl1" of group "grp1" to "Group level field"
and this works... BUT... recently, on more than one occasion, this has not worked and LC seems to 'mix up' / 'become confused' as to which control I mean to reference with the 'set the text of field "ctrl1" to "Card level field" ' command line.
Like I say, 99% of the time LC understands what I mean simply by my adding / omiting the 'of group...' syntax.
By '99% of the time', it would be more accurate to state that, once LC has decided to reference the group control even though I don't add the 'of group...' syntax, it will then do so forever - each and every time the code line executes. LC does not change its mind once its made up. This is true even following an SDK / computer reboot...
If, I trap the error / insert a breakpoint immediately after the offending line and then message box : 'put the ID of the field "ctrl1"' (note, no ' of group...') I get one ID (764586)
but clicking on the control I get another ID (584239)
then if I message box : 'put the ID of the field "ctrl1" of group "grp1" ' I get the same ID as that without the 'of group...' line (764586)
I guess I've ;
-1- not fully read / understood the nuances of control naming within LC and
-2- gotten away with it for a long time (looks like I may have to go and change quite a lot of code)
-3- I'm unsure as to how LC 'finds'/'matches' the control I'm referencing with my friendly name ( 'ctrl1' ) to its numeric ID (764586). Hadn't given it a thought until now...
Would someone enlighten me on control naming conventions with LC please and how (apart from renaming duplicate control names preferably) I can get around this issue.
Like I say, this occurs only occasionally; sometimes I can 'fix' the issue by creating a new control and then deleting the 'faulty' one... sometimes not - it's a very hard 'bug' / issue to recreate and therefore track down. I'm not sure if copying groups of controls from one card to another is my problem creator or not - sometimes a data entry control set (group) on one card is similar to that on another card, so I've copied, pasted and then modified an existing group from a different card to suit a slightly different (but similar) purpose on a new card. Maybe that's just 'asking' for problems.
Hope someone can kick me in the right direction.
Thanks a million.
<EDIT>
In fact, typing ' put the ID of field "ctrl1" of card "crd1" ' produces the same result (764586) as ' put the ID of field "ctrl1" of group "grp1" ' (764586)
whereas, if I type ' put the ID of field "ctrl2" of card "crd1" ' produces 782419 and a different result for ' put the ID of field "ctrl2" of group "grp1" ' (839126)
To me (a noobie to LC) this is a strange result... in that it does not appear to be repetetive / common...
Someone else must have experienced this and (hopefully) found a (simple/non-destructive) way around it... ? ! ? hopefully
Ideas ?