From RPTools Wiki
Jump to navigation Jump to search

oldFunction() Function

Introduced in version 1.3b51
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. Note: Do not rely on a specific order in the function chain unless you are sure that the functions will be redefined in that order. Calls to defineFunction() within onCampaignLoad macros on different Library Tokens are not executed in any standard order.




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


Within a user-defined function named eval(), oldFunction() is used to call the standard MapTool eval() function.
[h, if ( arg(0) == 0 ), code:
    [h: macro.return = 0]
    [h: macro.return = oldFunction( arg(0) ) ]
By having access to the original function definition, this example is able to provide custom or standard return values when called.

See Also