Redefinition of functions from a DLL

[Autolink] Menu

You can also redefine a function loaded from a DLL, for example REXXUTIL.DLL (see RxFuncDrop and Call by value for an example for using this technique):

 
/* example to redefine a function from the DLL REXXUTIL               */

  say "Now calling SysCurPos with (4,5) ..."
  rc = SysCurPos( 4 , 5 )
  say " rc = " || rc

  say "Now calling SysCurPos with (x,y) ..."
  rc = SysCurPos( "x", "y" )
  say " rc = " || rc

exit

                        /* new SysCurPos function                     */
SysCurPos: PROCEDURE
  parse arg p1,p2

                        /* check the type of the parameter            */
  if datatype( p1 ) <> "NUM" | datatype( p2 ) <> "NUM" then
    thisRC = "Invalid parameter!"
  else
  do
                        /* load the original function if not already  */
                        /* loaded                                     */
    if RxFuncQuery( "SysCurPos" ) then
      call RxFuncAdd "SysCurPos", "REXXUTIL", "SysCurPos"

                        /* call the original function                 */
    thisRC = "SYSCURPOS"( p1,p2 )
  end /* else */
RETURN thisRC

(see also Redefinition of internal functions)


[Back: Redefinition of internal functions]
[Next: Loading more than one DLL with the same function names]