Data types and Operators

Operator : Foundation

Send operator (binary): sends a message to an object.

<Object>:<Message>[( <Arguments,...> )]
<Object> is an expression which returns a reference to the object to which a message should be sent.
<Message> is the name of a member variable which is to be accessed or the name of a method which is to be executed.
<Arguments,...> is a comma separated list of expressions which must be enclosed in parentheses. The values of the expressions are passed to the method executed by the message <Message>. When parentheses are not used a member variable is always accessed.

The send operator sends a message to an object. The names of member variables and methods which are declared in the class can be sent as messages. A member variable is accessed when the message <Message>is used without parentheses in the source code. The result of the message is the value or contents of the applicable member variable. A method is executed if the message is used with parentheses. The optional arguments from the list <Arguments,...> are passed to the method. In this case, the result of the message is the return value of the method.

Only names for member variables and methods visible at this point in the program can be sent as a message. Other than the code that implements the methods, the only member variables and methods visible are those declared with the visibility attribute EXPORTED:. The visibility within the source code for methods depends on the visibility attributes HIDDEN: and PROTECTED:. With member variables, write access (data assignment) can be limited, in addition to the visibility. When write access is limited, assignment of values to member variables can occur only within the source code for methods and not in the other source code of the Xbase++ application.

When the message <Message> is not declared in the class or when the corresponding member variable or method is not visible, a runtime error is generated.

The send operator (:)
// In this example a TBrowse object is created. The send operator 
// is demonstrated by calling methods and accessing member variables 
// of this object. 

   LOCAL oBrowse, oColumn, n 

   USE Customer NEW                 // open file 
                                    // execute class method :new() 
   oBrowse := TBrowse():new( 10, 10, 20, 60 ) 

                                    // assign instance variables 
   oBrowse:goTopBlock    := {|| DbGoTop() } 
   oBrowse:goBottomBlock := {|| DbGoBottom() } 
   oBrowse:skipBlock     := {|n| DbSkipper(n) } 

   FOR n:=1 TO Fcount()             // generate TBColumn objects 
      oColumn:= TBColumn():new( FieldName(n), FieldBlock(n) ) 
      oBrowse:addColumn( oColumn )  // attach TBColumn object 

   oBrowse:forceStable()            // display data rows 


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.