Progress
External Program
Interfaces
Example HLC Application
This section explains how to use the Progress HLC tank demo application. This application is a prepackaged application that you can use to verify that your HLC environment is set up correctly. The C code and sample output for this example are provided in the
$DLC/probuild/hlc/examples
directory on UNIX, and in the%DLC%\probuild\hlc\examples
directory in Windows.Set up your environment and compile this example before you try to run it to verify that your compiler and the PROBUILD utility are working correctly. This also helps you learn how to use HLC in a controlled environment.
This sample application uses Progress to keep track of oil storage tanks. Your Progress procedure calls a C program,
AVCALC
, to calculate the available capacity for a given tank. Figure 2–6 shows that the tanks are cylindrical, with their axes parallel to the level ground.Figure 2–6: Tank Positioning and Orientation
![]()
To calculate the available capacity (empty portion) of the tank, you need to know the tank’s diameter, length, and current level of oil. Use the variables in the following formula to calculate the available tank volume:
![]()
Where:
For this example, assume there is a tank table for this application that contains the following decimal fields:
radius Radius of tank tlength Length of tank depth Level of oil—must be between 0 and (2 . radius) tavail Available volume in tank
In addition to these fields, the tank-id character field is used as the primary index.
Figure 2–7 shows the Data Dictionary report for the tank table.
Figure 2–7: Progress Data Dictionary Report For Tank Application
A C function calculates the tavail field from the other three decimal fields (radius, tlength, depth). Figure 2–8 shows the Progress procedure that invokes the C function by calling the HLC routine,
AVCALC.
Figure 2–8: Progress Procedure Calling HLC Routine AVCALC
Make a copy of the HLC dispatch routine,
hlprodsp.c
, and name ittankdsp.c
. Modify the routine so that an entry appears forAVCALC
, which calls the C subroutinehlvcalc
.Example hlprodsp.c shows the modifications to the
tankdsp.c
routine:
The following procedure shows the code for the demo program,
hlvcalc.c
. The program extracts the radius, length, and level fields from the shared buffer tank, calculates the available volume, and updates the tavail field in the shared buffer tank with the number calculated:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |