Properties (Integer, String, etc) on a Window (or WebPage) or within a ContainerControl (or WebContainer) can have their Scope set as Protected (versus Private or Public).
As I understand it, when the Property is set as:
Private, it is only visible and accessible from within the Object it is in
Protected, it is visible and accessible from other Objects, Classes and Modules, but must be addressed directly with its full path
Public, it is visible and accessible from other Objects, Classes and Modules, and can be addressed by name alone (leading to potential confusion in code)
Yet, when a Property is set as Protected, it cannot be accessed from any other Object than the Object that it is within. As a result you must set it as Public. This is NOT the case the Properties within Modules, where Protected Properties ARE visible and accessible.
The compiler error is: This property is protected. It can only be used from within its class.
The net result is there is no use for the Protected scope, except for Properties within Modules, you have to make the Properties either Private or Public.
This is an issue for both Desktop and Web Apps.
In the provided examples, the Window/WebPage cannot set the Property on the embedded container, nor can the embedded container set the Property on the Window/WebPage, despite being given the path to the Property.
For classes (windows, custom class etc)
private is visibile only from the same istance
protected is visible from the istance and subclasses
public is visible from everywhere but you have to specify the istance
shared private is visible only from the original class
shared protected is visible from the class, subclasses and their istances
shared public is visible everywhere but you have to specify the class or subclass
for modules:
public is visible every where
protected is visible only with qualified name (ie modulename.property) or in class within the module
private is visible only in module or in classes within the module
[quote=493009:@Greg O’Lone]The scopes you are describing are the way they apply to items in a Module, not Classes.
In the case of Classes, Protected means that the item is only accessible to the item itself and subclasses of the class.[/quote]
If I add a Label to a window I agree, the choice is Public or Private, but if I add an Integer Property to that same window I have the choice of Protected, Public or Private, yet in this case setting this Integer as Protected is of no worth to anyone.
I think it would refer to a subclass of the container and not an instance of the container on a window.
Couldn’t you make the container objects public as I don’t see any benefit of just making them protected if you are going to access them from the window.
Alternatively, you could provide accessor methods in the container that access the objects.
[quote=493018:@Kevin Gale]Couldn’t you make the container objects public as I don’t see any benefit of just making them protected if you are going to access them from the window.
[/quote]
Thanks Kevin, this is what I do, but it annoys me! It means I have more items set as Public than I would prefer. Why can’t I have them work the same way as Properties in a Module it is inconsistent.
I don’t give a RR what they are, they work in an inconsistent way. I can see that under the bonnet/hood why things work a certain way, but is it possible they could be made to work consistently, rather than ‘That’s the way we always build our cars’?
I will stop shouting at windmills.