Silvio,
Normally you would do something like this:
- Code: Select all Expand view
Method SetUpper( lUpper )
if lUpper != nil
::lUpper:= lUpper
endif
return ::lUpper
Method Whatever( cString )
if ::lUpper
cString:= upper( cString )
endif
return cString
Note that you could just access ::lUpper directly like oObj:lUpper:=.t. without the setUpper() method, but OOP principles state that no DATA should be accessed directly, but rather should be set using a method. This does prevent data from being changed that may depend on other settings (DATA) being set a particular way, and visa versa. I think this is a bigger concern when you have multiple programmers working on a project that might not be fully aware of the consequences of changing DATA directly.
However, your definition could work. Did you try it? However, if you need to pass something to either func1() or func2() then they would have to be passed to the setUpper() method which is very confusing. It is better to set the DATA (::lUpper) then use that data in a method that does different things depending on its value (such as my Whatever() method).
James