Statement ACCESS | ASSIGN Foundation
Declares a redirection for member variable access
ACCESS | ASSIGN [CLASS] METHOD <MethodName> [VAR <VarName>] or ACCESS ASSIGN [CLASS] METHOD <MethodName> [VAR <VarName>]
The syntactical notation object:varName for accessing a member variable leads to a redirection of the message sent to an object. When the member variable is accessed, a method is called. The return value of the method <MethodName> then defines the value of the accessed member variable. In case of an ASSIGN method, the value to be assigned to the member variable is passed as parameter to the method. The message redirection only takes place when the member variable is accessed from outside the method. Within the program code of the method no redirection occurs and the member variable can be accessed directly.
Encapsulation of member variables
If the member variable <VarName> is declared in the class, access to it can be completely encapsulated by ACCESS and ASSIGN methods. Read access invokes an ACCESS method and write access calls the ASSIGN method. Read access occurs when a member variable's value is retrieved from an object, while write access takes place when changing a member variable's value. A method can be declared for one or both types of access.
Computed member variables
If the member variable is not declared in the class with the VAR statement, the identifier <VarName> serves as message for invoking the method <MethodName>. In this case, an appropriate value must be determined within the method implementation and returned. This way, an object appears to have a member variable, but the member variable's "value" is always the computed return value of a method (see the example).
Redirections established using ACCESS and ASSIGN methods behave according to the following rules:
Once declared, the redirection remains established for the lifetime.
The method <MethodName> can be overloaded in subclasses.
Introduction of ACCESS and ASSIGN methods for member variables inherited from superclasses is supported.
In case a member variable is encapsulated by a ACCESS or ASSIGN method, the member variable can only be accessed inside the ACCESS and ASSIGN methods. All other methods accessing the member variable are redirected to the ACCESS and ASSIGN methods.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.