%XADDR

Return the address of a routine

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
address = %XADDR(subroutine, [elb][, notfound])

Return value

address

The address of a function or external subroutine that can be used as the first argument to the XSUBR subroutine. The result is integer data type. Variables used for the return value should be declared as type D_ADDR, which is defined by the compiler as either i4 or i8, depending on the system. (D_ADDR)

Arguments

subroutine

The name of the subroutine whose address will be returned. (a)

elb

(optional) The ELB (in traditional Synergy on Windows or Unix), DLL (in Synergy .NET), or shared image (on OpenVMS) that contains the routine. (a)

notfound

(optional) If nonzero, a value that causes the return value to be 0 if the subroutine is not found. (n)

Discussion

%XADDR returns an integer value that can be used to access the specified subroutine. It is intended to be used in conjunction with the XSUBR subroutine when you need to invoke the same subroutine more than once.

Note

You cannot use %XADDR to return the address of a class method.

On Windows and Unix, if elb is not already open, it is opened, along with any ELBs that it is linked against. You can use an environment variable to specify the location of the elb. For example you can pass “ELBDIR:elb_name” to %XADDR.

In Synergy .NET, %XADDR does not use an .elb extension for the second argument. It opens .NET assemblies according to the rules for loading assemblies in .NET. Assemblies can be loaded using a partial name (e.g., Synergex.SynergyDE.synxml), a fully qualified name (e.g., Synergex.SynergyDE.synxml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=114C5DBB1312A8BC), or a full path (e.g., C:\Windows\assembly\GAC_MSIL\
Synergex.SynergyDE.synxml\2.0.0.0__114c5dbb1312a8bc\Synergex.SynergyDE.synxml.dll). Microsoft’s recommended practice when loading assemblies is to use the fully qualified name when possible, to prevent versioning issues.

Only public routines (those not marked INTERNAL) can be used with XADDR in Synergy .NET.

We strongly recommend against using %XADDR for device development. If there is no compile-time binding for this routine, it won’t be included in the compiled device application (even if there are runtime bindings). Additionally, the elb argument for %XADDR is supported only when OPENELB is supported.

On OpenVMS, elb is the name of an OpenVMS shared image. Only the filename section is used; all other elements are ignored. The name can be either the filename of a shared image located in SYS$SHARE, or a logical name that refers to a shared image, which may reside anywhere. A routine in a shared image will only be found if the shared image is explicitly specified or an OPENELB has been done on the shared image.

Normally, if the routine is not found, a “Cannot access external routine” error ($ERR_RTNNF) is signaled. If notfound is passed as a nonzero value and the routine is not found, address is returned as 0, and no error is signaled. If the specified ELB or any linked ELB is not found, the runtime generates a “File not found” error ($ERR_FNF).

See also

XSUBR routine

Examples

record
    adr         ,D_ADDR
proc
    adr = %xaddr("U_START", "WND:tklib.elb")
    if (adr)
      xcall xsubr(adr)                   ;xcall U_START