Harbour Reference Guide

 

__objAddMethod()

Add a METHOD to an already existing class

Syntax

__objAddMethod( <oObject>, <cMethodName>, <nFuncPtr> ) --> oObject

Arguments

<oObject> is the object to work on.

<cMethodName> is the symbol name of the new METHOD to add.

<nFuncPtr> is a pointer to a function to associate with the method.

Returns

__objAddMethod() return a reference to <oObject>.

Description

__objAddMethod() is a low level class support function that add a new METHOD to an object. <oObject> is unchanged if a symbol with the name <cMethodName> already exist in <oObject>.

Note that <nFuncPtr> is a special pointer to a function that was created using the @ operator, see example below.
Examples
      // create a new THappy class and add a Smile method
      oHappy := TClass():New( "THappy" )
      __objAddMethod( oHappy, "Smile", @MySmile() )
      ? oHappy:Smile( 1 )       // :)
      ? oHappy:Smile( 2 )       // ;)
      ? oHappy:Smile( 3 )       // *SMILE*

      STATIC FUNCTION MySmile( nType )
      LOCAL cSmile
      DO CASE
         CASE nType == 1
              cSmile := ":)"
         CASE nType == 2
              cSmile := ";)"
         CASE nType == 3
              cSmile := "*SMILE*"
      ENDCASE
      RETURN cSmile
Status

Ready

Compliance

__objAddMethod() is a Harbour extension.

Files

Library is rtl

See Also

 




[Source Forge]

Other Docs Categories

Advantage Database RDD
Array
Binary conversion
Classes
Code Block
Console input
Conversion
Conversion Tools
DOS
Data input and output
Database
Database Tools
Date
Dos Tools
Environment
Error recovery
Events
File management
GT
Harbour Tools
Internal
Low Level
Math
Misc
Miscellaneous
Nation
Object manipulation
Operating System Specific
Parameter Checks
String Tools
Strings
TBrowse Method
TBrowse class
Terminal
Time
Utility
Variable Management

 

Last updated on 2001/06/26