Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Private properties in defined class
Message
 
 
To
18/09/2002 20:02:39
Jordan Pastourel
Worksafe Management Systems
Toowong, Australia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00702088
Message ID:
00702237
Views:
14
Jordan,
You can do this using the PROTECTED keyword:
DEFINE CLASS objectGet as Custom OLEPUBLIC

PROTECTED ListArray
ListArray = 0

Procedure getValues
   ** retrieves values from the ListArray
   return THIS.ListArray
EndProc
ENDDEFINE
When a property is configured as protected, you can only access from within the class itself. If you create an object reference to ObjectGet and attempt to access the ListArray property directly using ObjectGet.ListArray, VFP will throw an error saying the property does not exist.

The difference between this method and the one Sylvain posted is that you can access ListArray from outside the class if you have an _Access method. All accesses (internal/external) to the property are directed through the _Access. To tell the difference, you would need to parse up the call stack to determine if an internal method was accessing it.

HTH.

>Hi all,
>how do i create a private property in a class? is this correct?
>
>
>DEFINE CLASS objectGet as Custom OLEPUBLIC
>
>private ListArray
>
>Procedure getValues
> ** retrieves values from the ListArray
>
>EndProc
>
>ENDDEFINE
>
>what i want to happen is the class has the ListArray as a property, but can't be accessed directly, instead it is to be accessed through the getValues procedure. Am i on the right track?
>thanks
>Jordan
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform