Consultor Eletrônico



Kbase 16059: HLC: Basic Info on building VMS Progress Client C functions
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
HLC: Basic Info on building VMS Progress Client C functions


What is an HLC applicaton?
--------------------------
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 executible
that includes all of the C object-code where these C functions
exist.

Where are the files located?
----------------------------
On VMS systems for version 7.3C+, the HLC files are located in
the PROBUILD directory which is located in the DLC directory.
For example, if your DLC logical is defined to point to this
location: DISK1:[PROGRESS7.DLC], then the HLC files and
examples are located in DISK1:[PROGRESS7.DLC.PROBUILD.HLC] and
DISK1:[PROGRESS7.DLC.PROBUILD.HLC.EXAMPLES].

(Please note: These directory names may change, use them as
guidelines to help find or locate appropriate files. Also, the
directory paths will vary depending on how you installed
progress.)


How do you build an HLC application?
------------------------------------
First you need to write your C functions and compile them into
object files. You also need to edit the hlprodsp.c file so that
it has all of the interface definitions you need for all of the C
functions you want to call. Be sure to compile hlprodsp.c also.

You then need to run PROBUILD to build a Progress executible.
You can do this by selecting Progress Client from the Product
List screen when running PROBUILD. You can specify an executable
name or leave the default which is progres. If you choose to use
the default, we recommend that you run the .com from your home
directory, or from a sub-directory under sys$login. This was you
can be sure you are not overwriting the standard progres exe
that was shipped. From the Configurable Elements screen, choose
HLC application (you may have to scroll to see this choice). You
may have other choices you want to select as well as this. Enter
all of the C function object files that you need including the
hlprodsp.o.

This generates a link command procedure, named ldpro (unless you
renamed it) that when run will link together all of the Progress
libraries and the C functions that you specified. (Please refer to
the Progress External Program Interfaces and System Administration
Guide/appendix B, for more information on using PROBUILD.)

Now, you should be able to start progress using your new progress
executable (or whatever you named it) and run your 4gl
application. The 4gl application should be able to call the C
functions that were included.


Here is an example:
-------------------
See below a 4gl program that CALLs testproc (a C routine):

def new shared var errcode as int.
call TESTPROC.
if errcode = 3 then message "error".
else message "errcode = " errcode.


Here is the C function testproc():

int testproc()
{
int i;
i = prowti("errcode",0,3L,0);
return 0;
}

Here is the hlprodsp that defines the interface between Progress
and the C routines:

/* PROGRAM: HLPRODSP
*
* Purpose:
* Dispatch routine for CALL statement
*
*/

long
PRODSP(pfunnam, argc, argv)

char *pfunnam; /* Name of function to call */
int argc;
char *argv[];

{
/* Use the FUNCTEST macro to set up the calls to your
* C programs, e.g, if you want CALL FOO to call the
* entry point mytrig(), say:
*/

FUNCTEST("testproc", testproc)
return 1;
}


To build this HLC application, you need to first compile
testproc.c and hlprodsp.c into object files.

Then, when running probuild in the manner described above,
include these object files. Now, when you run the resulting
link script these objects will be linked in also.

Run ldpro.com (at the $ prompt, enter @ldpro)

Run the new progres.exe by re-defining the logical for PROEXE to
point to your new executable.

Bring up the small 4gl program shown above and run it.


Written References:
Version 7 Progress Programming Handbook Ch 4
Version 7 External Program Interfaces
Version 7 System Administration Guide, Appendix B, Probuild

Progress Software Technical Support Note # 16059