Consultor Eletrônico



Kbase P40782: How to call a C procedure from Progress.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/25/2005
Status: Unverified

GOAL:

How to call a C procedure from Progress.

GOAL:

Differences in the various methodology of calling an external C routine. (HLC vs. DLL/Shared Library vs INPUT THROUGH).

GOAL:

How to trap signals of a C routine from Progress.

GOAL:

Which to use? HLC, DLL/Shared Library or INPUT THROUGH ( trap signals )

GOAL:

What is HLC?

GOAL:

Why call C functions from the 4GL?

FIX:

You may want to perform some low-level functionality that is not easy to do directly with a 4GL. For instance, you may want to interface directly with a device or support trigonometric or other special numeric functions or directly access third-party proprietary data files such as spreadsheets.

- What is HLC

HLC allows users to call C functions from the 4GL using the CALL statement. In order to use the CALL statement to call a C function, however, you first need to build a Progress executable that includes all Progress code linked with your C functions. Please see the Host Language Call Interface Chapter in the External Program Interfaces guide for more detail on how to build HLC applications.

- Other options available:

On Windows platforms you can use Dynamic Link Libraries (DLLs) to call routines from the 4GL. An application links to these routines at runtime rather than at build time and shares DLL code with other applications. Any enhancement to a DLL immediately becomes available to your application. For more info on using DLLs,see Chapter 4 of the External Program Interfaces guide.

On UNIX platforms you can use Shared Libraries to call routines from the 4GL. These work the same as DLLs do on the Windows platform.

On UNIX and Windows NT/2000/XP platforms you can use INPUT THROUGH or INPUT-OUTPUT THROUGH. These features are documented in the Programming Language Reference guide.


- HLC, DLL/Shared Library and INPUT THROUGH: main differences

It is important to know that Progress (UNIX) relies on signals from the operating system for its client to server communication. If you need to trap signals in your application extensions, then HLC is not the recommended approach as it could interfere with the integrity of your database and you could experience unexpected behavior in your application. Instead of using HLC, which bundles the C routine into the same process space as your 4GL code, it is better to use an approach where your extensions are part of a separate process and therefore have its own signals and signal handlers.

In the case where you need to trap signals, the INPUT THROUGH or INPUT-OUTPUT THROUGH approach is recommended.
You can start your C application off as a separate process and communicate with it. NOTE: INPUT-OUTPUT THROUGH is available on NT/2000/XP and UNIX only.

NOTE: The DLL/Shared Library approach will not work in the case where you need separate process space because when Progress loads a DLL/Shared Library, that DLL/Shared Library becomes part of the same process.


- Using HLC to trap signals.

Even it is strongly recommended that you do not use HLC in an application that requires trapping and handling of your own signals in the C code, it is possible for an experienced C programmer to find out what signal handlers are being used and to replace them at the beginning of each C routine with your own signal handler. The programmer would then have to be sure to replace the original signal handlers before leaving the C routine IN ANY WAY. This is very tricky and hard to do. It is not recommended and would be the full responsibility of the programmer. This type of programming in the context of HLC is not supported by Progress.