Patching existing functions

Whenever I have to correct a function from the HTMLSave` package, I either have to rewrite the whole function, but mostly, I just need to apply a few changes to the result that is returned by the function. In the latter case, one can use a construct like the following:

function[ args___ ] /;!TrueQ[UsePatchX] := Block[ {UsePatchQ=True,res},
(*any custom settings for the function, e.g. changing args: *)yourowncode;
(*call to original function: *)res=function[args];
(*change the result:*)yourowncode1;

The /;!TrueQ[UsePatchX] and the Block[{UsePatchX},...] are needed to that inside the block the old definition for the function is called and not our newly defined one.

Back to Main Page...

Converted by Mathematica      May 27, 2001
Thanks to SourceForge for hosting lots of GPLŽed software projects!!! SourceForge Logo