Harbour Reference Guide

 

__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. <oObject> is unchanged if a symbol with the name <cMethodName> does not exist in <oObject>. __objModMethod() is used in inheritance mechanism.

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 )       // ;)
      // 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

 




[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