__OBJMODMETHOD()
Modify (replace) a METHOD in an already existing class
- Syntax
- __objModMethod( <oObject>, <cMethodName>, <nFuncPtr> ) --> oObject
- Arguments
- <oObject> is the object to work on.
- <cMethodName> is the symbol name of the METHOD to modify.
- <nFuncPtr> is a pointer to a new function to associate with the method.
- Returns
- __objModMethod() return a reference to <oObject>.
- Description
- __objModMethod() is a low level class support function that modify a METHOD in an object and replace it with a new function. is unchanged if a symbol with the name does not exist in . __objModMethod() is used in inheritance mechanism.
- Note that 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 ) // ;)
- // replace Smile method with a new function
- __objAddMethod( oHappy, "Smile", @YourSmile() )
- ? oHappy:Smile( 1 ) // *SMILE*
- ? oHappy:Smile( 2 ) // *WINK*
- STATIC FUNCTION MySmile( nType )
- LOCAL cSmile
- DO CASE
- CASE nType == 1
- cSmile := ":)"
- CASE nType == 2
- cSmile := ";)"
- ENDCASE
- RETURN cSmile
- STATIC FUNCTION YourSmile( nType )
- LOCAL cSmile
- DO CASE
- CASE nType == 1
- cSmile := "*SMILE*"
- CASE nType == 2
- cSmile := "*WINK*"
- ENDCASE
- RETURN cSmile
- Status
Ready
- Compliance
- __objModMethod() is a Harbour extension.
- Files
- Library is rtl
- See Also