REXX Tips & Tricks, Version 2.80

Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs

The REXX API functions

If the function <RxFuncAdd returns 0 this only means that the new function 
is registered. It does not mean that you can use this function! The same 
is true for the function <RxFuncQuery. 


  say rxFuncAdd( "TestFunc1", "REXXUTIL", "TestFunc1" )
                        /* result is 0 (= function registered!)       */
  say rxFuncQuery( "TestFunc1" )
                        /* result is 0 (= function registered!)       */
  call TestFunc1
                        /* error: Function not found!                 */

To use a DLL which does not exist in one of the directoies in the <LIBPATH 
you can use a fully qualified path for the name of the DLL containing the 
functions. But be aware that functions like <SysLoadFuncs will not work in 
this case because they expect the DLL to be in the <LIBPATH. You have to 
register all needed functions from the DLL manually using <RxFuncAdd. This 
is true for REXXUTIL and mostly all DLLs exporting a function to register 
the other DLL functions. (Source: Documentation for the REXX 
A name for an external function (the first parameter for the function 
RxFuncAdd) can only be registered once. So, if you want to reRegister a 
name you must first deRegister it using <RxFuncDrop before registering it 
(or use another REXX name, see Loading more than one DLL with the same 
function names) 
The conclusion from the statements above: To register a function you 
should use a routine like the following: 

                        /* install a temporary error handler          */
                        /* note: the previous error handler is auto-  */
                        /*       maticly restored a the end of the    */
                        /*       routine                              */

                        /* set a marker                               */
  dllInitOK = 0

                        /* first deregister the function              */
  call rxFuncDrop "InitMyDll"

                        /* load the function                          */
  dummy = rxFuncAdd( "InitMyDll", "MYDLL", "InitMyDLL" )

                        /* call the init function                     */
  call InitMyDll
  dllInitOK = 1         /* set the marker, this statement is not      */
                        /* executed if the previous statement fails!  */

                        /* deRegister the name if the init call       */
                        /* failed                                     */
  if dllInitOK = 0 then
    call rxFuncDrop "InitMyDll"

                        /* returns: 1 - dll init ok                   */
                        /*          0 - dll init error                */

Note:  see also DLL loading failed, Loading more than one DLL with the 
       same function names and RxFuncDrop 

Inf-HTML End Run - Successful