Calling external functions on UNIX

In PowerBuilder custom class user objects that you plan to deploy as EAServer components on a UNIX platform, you can call external functions in shared libraries compiled on the operating system where the server is running. You cannot call external functions in libraries that make Windows API calls or rely on graphical processing.

You use the standard PowerScript syntax to declare functions that reside in UNIX shared libraries. For example, this statement declares the function getcwd in the standard C library on Solaris:

FUNCTION string getcwd(REF string buff, &
		unsigned int size) LIBRARY "/usr/lib/libc.so"

You call the function from a script in your application in the way you call any other function. In this example, the space function allocates enough space to hold the directory name returned by getcwd:

string ls_return, ls_directory
ls_directory = space(100)
. . .
ls_return = getcwd(ls_directory, 100)

NoteUpdating the load library path On UNIX, when your component calls an external function, it must be able to find the shared library in which that function resides. To ensure this, you must update the library path environment variable to include the directory where that shared library is stored.