oldFunction: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
m (Clarified that user-defined functions can be redefined as well, and gave a basic explanation of function chaining.)
Line 3: Line 3:
|name=oldFunction
|name=oldFunction
|description=
|description=
If a user-defined function redefines a standard MapTool function -- for instance, a user defines a function called {{code|eval()}}, redefining the standard MapTool {{func|eval}} -- {{func|oldFunction}} can be used in the user-defined function to call the original function.
If a user-defined function redefines a standard MapTool function or another user-defined function -- for instance, a user defines a function called {{code|eval()}}, redefining the standard MapTool {{func|eval}} -- {{func|oldFunction}} can be used in the user-defined function to call the original function. When a user-defined function redefines an existing function, it keeps track of the function that it redefined. Due to this tracking, it is possible to redefine a function multiple times and {{func|oldFunction}} will always reference the previous function in the chain.
 
|usage=
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>

Revision as of 20:19, 16 April 2009

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.

oldFunction() Function

If a user-defined function redefines a standard MapTool function or another user-defined function -- for instance, a user defines a function called eval(), redefining the standard MapTool eval() -- oldFunction() can be used in the user-defined function to call the original function. When a user-defined function redefines an existing function, it keeps track of the function that it redefined. Due to this tracking, it is possible to redefine a function multiple times and oldFunction() will always reference the previous function in the chain.

Usage

oldFunction(SPECIAL)

Parameter

  • SPECIAL - oldFunction supports the same parameters as the function that it is referencing.

Examples

Used within a user defined function named eval(), oldFunction() is used to call the standard eval().
[h, if ( arg(0) == 0 ), code:
{
    [h: macro.return = 0]
};{
    [h: macro.return = oldFunction( arg(0) ) ]
}]

See Also