Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Calling external functions and programs on UNIX – PB Docs 70 – PowerBuilder Library

Calling external functions and programs on UNIX – PB Docs 70

Calling external functions and programs on UNIX

When you work with PowerBuilder on the UNIX platform, there
are UNIX-specific considerations for:

  • Calling external functions
    in PowerBuilder
  • Running other programs

About calling external functions

On UNIX, you can call external functions in shared libraries
from several sources:

  • UNIX versions of Windows
    API DLLs
  • Existing UNIX shared libraries
  • UNIX shared libraries you developed on UNIX or ported
    from Windows

You use the standard PowerScript syntax to declare functions
in these libraries, but the LIBRARY parameter must refer to a shared
library compiled on your operating system.

note.gif On UNIX On UNIX, when you create a compiled code executable for an
application that makes external function calls, you can ignore any
error messages like the following:

Using Windows API DLLs on UNIX

The Wind/U layer of PowerBuilder provides UNIX shared
library versions of the following Windows API DLL files (the UNIX
file extension depends on the UNIX platform):

Windows API DLL UNIX shared library equivalent
USER32.DLL libuser42
GDI32.DLL libgdi42
KERNEL32.DLL libkernel42

When you declare a function in one of these libraries, you
must adhere strictly to the correct parameter types. For example,
if the Windows SDK function has a parameter of type DWORD, you must
declare that parameter as an unsigned long in PowerBuilder.

For a comparison of data types in external
functions and data types in PowerBuilder, see the section on declaring
and calling external functions in the PowerScript Reference
.

For examples showing how functions in these
libraries are declared, see “Declaring external
functions”
or the Windows SDK example in the
Code Examples sample application.

Using existing shared libraries on UNIX

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

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:

Using your own shared libraries

You use the standard PowerScript syntax to declare functions
that reside in shared libraries that you developed. If you have
Windows DLLs that you want to port to UNIX, you will usually have
to port the C or C++ source code to UNIX and recompile.

If you are porting Windows DLLs that make Windows API calls,
you need to use a product such as Wind/U from Bristol Technology
to provide a translation layer for handling those calls in UNIX.
For more information about Wind/U, contact Bristol Technology.

note.gif Updating the load library path On UNIX, when your application calls an external function,
it must be able to find the shared library in which that function
resides. To ensure this, you must update your library path environment
variable to include the directory where that shared library is stored.
You need to do this in your development environment to test the
application and on end-user systems where the application is deployed.

Running other programs

You can use the PowerScript Run function to initiate a process
from your PowerBuilder application. This technique forks a child process
(although it does not provide you with the process ID for that child
process).

For example, the following statement initiates a process that
executes the vi editor application:

Starting a shell from your application

One reason you might want to code the Run function in your
application is to initiate a process that starts a shell. Doing
this enables you to take advantage of shell capabilities, such as
shell script invocation.

For example, to invoke a C shell script named myscript.csh,
use this statement:

When coding arguments for the Run function, you cannot include
shell-related variable values (variables that require interpretation
by a shell). For example, the Run function can’t interpret
environment variables such as $HOME or metacharacters such
as ~.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x