Property on window or Container not accessible if Protected

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:

  1. Private, it is only visible and accessible from within the Object it is in
  2. Protected, it is visible and accessible from other Objects, Classes and Modules, but must be addressed directly with its full path
  3. 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.

feedback://showreport?report_id=60694
Sorry if you cannot access this case as Feedback wouldn’t let me save it as Bug.

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.

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.

Thanks, but my issue doesn’t refer to classes and modules, but Properties in a window or container.

Those are both classes.

OK, then a Container (sub class) sitting on a Window (class) should be allowed to access each other’s Protected Properties.

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.

For they are classes.
Modules are not classes.

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.

I don’t think it’s actually inconsistent. Modules don’t have the same options. Properties are “Global” “Protected” or “Private” not “Public”

This is one of the things you pick up on if you’re scoping your variables when defining their names.

Yet you go on to show an inconsistency.

Right.
(But the bases of the different cases that I listed before remains)

David, long time ago I had the same feeling. Now I think that it has a lot of sense and you will find very clear and useful once you got the habit.

No, they’re different scope levels.

A control on a window is not a subclass of the Window

[quote=493021:@Antonio Rinaldi]For they are classes.
Modules are not classes.[/quote]
wellll … sort of :slight_smile: