Consultor Eletrônico



Kbase P19651: HLC: Step by Step - How to build a Windows Progress client w
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/16/2004
Status: Unverified

GOAL:

HLC: How to build a Windows Progress client with C functions

GOAL:

How to build a Progress executable containing selfdefined C functions

GOAL:

How to implement hlc.h library when using HLC - ESQL/C

FIX:

1) REQUIREMENTS

To build PROGRESS clients, you need the appropriate PROGRESS license, a C compiler and a linker. See the installation guide and documentation for supported compilers.


2) WORKING ENVIRONMENT

You may create a working directory to place your source and compiled files. Don't use the PROGRESS DLC directory in order to avoid risks of accidentally altering the original PROGRESS files.

Put in this directory a PROGRESS.INI with the normal settings for your PROGRESS sessions. You must pay special attention to the PROBUILD and PROPATH parameters. PROBUILD must point to the Progress DLC/PROBUILD directory and PROPATH must include the DLC\PROBUILD\EUCAPP directory and DLC\PROBUILD\EUCAPP\EUC.PL library file.

Example:

PROBUILD=C:\DLC\PROBUILD
PROPATH=.,C:\DLC,C:\DLC\PROBUILD\EUCAPP,C:\DLC\PROBUILD\EUCAPP\EUC.PL

Additionally, because the compiling and linking must be done from the DOS prompt, you will need to set DOS LIB and INCLUDE environment variables. LIB must point to the C LIB directory and INCLUDE to the C INCLUDE directory.

Example:

set LIB=C:\MSVC\LIB
set INCLUDE=C:\MSVC\INCLUDE


3) C PROGRAM

You can include your C functions in one or more C programs.
If you are going to use HLC library functions, you must include the HLC.H header
file. This file is located in DLC\PROBUILD\HLC directory in V8.
If you are going to use Embedded SQL functions, you must include the PROESQL.H header file. This file is located in DLC\PROBUILD\ESQL directory in V8.

Example of C program "mytest.c":

#include "C:/dlcload/hlc.h" /* if V6 */
#include "C:/dlc/probuild/hlc/hlc.h" /* if V7 V8 */
int mytest (int argc, char *argv[]) {
promsgd("Hello World");
return 0;
}

4) HLPRODSP

C functions and PROPRESS functions may not have the same name. There is a file, hlprodsp.c, which translates 4GL calls into C function names. You must create and compile this file specifying the names you are using. An example of it is in DLC\PROBUILD\HLC directory.

Example of "hlprodsp.c" file:

#define FUNCTEST(nam, rout) \
if (strcmp(nam, pfunnam) == 0) \
return rout(argc,argv);
long PRODSP(pfunnam, argc, argv)
char *pfunnam; /* Name of function to call */
int argc;
char *argv[];
{
FUNCTEST("HOLA",mytest);
return 1;
}

Every C function called from 4GL must have the FUNCTEST declaration.


5) PROBUILD

Start PROBUILD
The working directory can be the one you are using for this test.

When you start PROBUILD, you may specify your working directory, choose "Progress client" from the PRODUCT LIST, accept the default LINK SCRIPT/EXECUTABLE NAMES and select "HLC applications" from the CONFIGURABLE ELEMENTS.

You may need to add more elements from the CONFIGURABLE ELEMENTS list depending on if you need access to remote databases, dataservers or gateways.

Next screen is the OBJECT FILES. Here you must type the HLPRODSP.OBJ and all your object files which contain your C functions, for example MYTEST.OBJ. It is not necessary to have previously compiled these files, since PROBUILD only builds the link script, doing nothing with the OBJ files specified.

Once PROBUILD has created the link script you can exit Windows or open a DOS prompt windows to compile and link the files. No matter if you modify and recompile your source files, the link script will always be the same and will not need to be re-created. You will need to run PROBUILD again only if you add or remove C source files or you want to add or remove configurable elements.

6) COMPILING

You must compile your C source files according the requirements of your C compiler and your PROGRESS/Windows environment. This example is using Microsoft Visual C++ compiler:

cl -Os -Gs -Zp -c hlprodsp.c
cl -Os -Gs -Zp -c mytest.c

You may add additional parameters if you need them.


7) LINKING

You mu.st simply invoke the Microsoft linker provided with your Visual C++ package using the link script built with PROBUILD.

Example:

LINK @PROWIN32.LNK

After linking you get the PROWIN32.DLL file.
(The Progress Client link script does not create a executable only a dynamic linked Library file which is caled by the prowin32.exe)

- Then make a backup of the original PROWIN32.DLL file
- Replace this file with the customized PROWIN32.DLL file
- You are now ready for next step, the test:


8) TEST !

Start the PROGRESS session from Windows, executing your PROWIN32.EXE.

In the PROGRESS Editor type the CALL statement to test your function.
For example:

CALL HOLA.

Note that you must use the name assigned in HLPRODSP.C instead of the C function name. Be careful with the case, because the PROGRESS CALL statement is case sensitive.

You should see a dialog box with the text "Hello World".


9) PROBLEMS ?

If you have not succeeded:
Repeat the steps carefully, if necessary start again from scratch. Be careful with environment variables, compiler parameters and the C source code. For test purposes you may use the examples shown here to ensure that your environment is correct..