In a refactor that I’m working on in converting both to Cocoa and the new Xojo IDE, I’ve removed some repetitive labels that were part of a Control Group of labels on a window. Basically, indexes 5-11 are no longer part of the project.
Should the compiler / analysis of the project note calls made to thee removed Indexes? I’m not seeing an error until runtime when a timer is updating the labels.
Contro groups are NOT required to be contiguous and IF your code relies on them being so then
you’re one of the folks who I would suggest use named instances and NOT a control group because your code relies on certain controls having certain indexes & you’d be better off with specific names as the compiler CAN catch that being absent
i.e. if you rely on
[code] const kNameIndex = 0
labelGroup(kNameIndex).text = “Hello world”[/code]
you’ll only find out at runtime that this code really should read
helloWorldLabel.text = "Hello world"
as the compiler cannot catch the first but will catch the second
The continuous nature is not required, just that I know what the indexes are. I was just curious as to whether this was something the compiler should be catching.
This code goes back to when using a control array for StaticText objects was more memory conservative. I was using specifically named StaticTexts and ran up against a performance issue (in 5.5 or so IIRC). Changing the 100’s of StaticTexts to an array really sped things up.
My new projects (since around 2010r2 or so) all use named Labels.
It can’t catch anything as it has no idea if the control with the given index may be created some time later - which is entirely possible