Not understanding Protected Scope

In creating a method I can opt for Public, Protected, or Private scope. I fail to understand what Protected is for and how it is used.
Ex: I have a window (ScrnA) on which I have placed a container (Ctr1). The containerControl has a method hndlPrint() which I wish to call from ScrnA. I will have other CC’s on this window, so I was trying to force the code to be myCtr1.hndlPrint() //the instance name to call the method. If I set the method’s scope to Protected, that code myCtr1.hndlPrint() autocompletes but, upon debug run, the compiler complains that the method is protected and can only be called from within its own class. Setting the method’s scope to Public, or course, allows the code to run.Setting it to Private prohibits the code from being called from anywhere other than within the Ctr1 class. So what is the use of Protected scope? I’m missing something, I know. :slight_smile:

ClassA is an Object.

ClassB is a ClassA.

ClassA defines a public method, MyPublicMethod. That can be called from anywhere.

ClassA defines a protect method, MyProtectedMethod. ClassA or ClassB can use that method.

ClassA defines a private method, MyPrivateMethod. Only ClassA may use that.

Thanks Kem. So in the instance I described, the only option is to set the method’s scope to Public and both myCtr1.hndlPrint() and hndlPrint() will function the same way. Do I understand?

…extending the above, so if I place other CC’s on the same window, I cannot give them hndlPrint() methods as the compiler will be confused as to which I am calling.

Where is a Class instance is concerned, you must prefix the method with the object reference. You must either use myCtrl.hndlPrint or, if you are implementing an event within that object on the window, me.hndlPrint. As such, you can have identical method names across many classes.

Ah, I think I would have intuitively gotten to that conclusion. Thank you, sir, for your explanations. Most helpful.