Consultor Eletrônico



Kbase 17377: How to build HLC application in UNIX?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to build HLC application in UNIX?

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
executable that includes all of the C object-code
where these C functions exist.


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 create your
prodsp.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 prodsp.c also. An empty template for a prodsp() routine
can be found in $DLC\probuild\hlc\hlprodsp.c.

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, be sure you are not overwriting the
standard _progres that was shipped or you may have to rebuild
it if needed. 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 prodsp.o.

This generates a link script named ldpro (unless you renamed
it) that when run will link together all of the Progress libraries
and the C functions that you specified.


Now, you should be able to start progress using your new _progres
(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):

/* testhlc.p: 4gl program that calls a c routine named testproc() */
def new shared var errcode as int.
call TESTPROC.
if errcode = 3 then message "error".
else message "errcode = " errcode.


/* testproc.c: C program that defines C function testproc()*/
int testproc()
{
int i;
i = prowti("errcode",0,3L,0);
return 0;
}

/* hlprodsp.c:
Here is the prodsp() that defines the interface between Progress
and the C routines
*/

/* PROGRAM: PRODSP
*
* 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 on Unix, you need to first
compile testproc.c and prodsp.c into object files.

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

Run ldpro.

Run the new _progres that was created by ldpro.

Bring up the small 4gl program (testhlc.p) shown above and run it.
Notice that your 4gl program can successfully CALL the c-routine
testproc().


Written References:
Version 7 Progress Programming Handbook Ch 4
Version 7 External Program Interfaces section 6.4.2 and 6.8.7
Version 8 External Program Interfaces chapter 2


Progress Software Technical Support Note # 17377