Progress
External Program
Interfaces


Source Code Listings

This section shows some of the source files provided in the $DLC/probuild/hlc/examples directory.

This procedure automatically loads the data definitions for the sample application:

loaddb.p
hide all.
display  skip(2)
        "  *********   LOADING the database ********* " skip(1)
        "  *********    please stand by............."
        with title "WELCOME TO HLC DEMO PROGRAM" 
                 row 5 centered frame hdr.
output to hldemout.
run prodict/load_df.p ("customer.df").
run prodict/load_df.p ("agedar.df").
run prodict/load_df.p ("monthly.df").
run prodict/load_df.p ("tank.df").
/* create signal file to indicate success */
if opsys = "unix" then do:
   unix  cat >hlcsigfile & .
end.
hide all. 

This is the Progress prototype file in which you define the application’s HLC routine identifiers and the corresponding C function names:

hlprodsp.c
#define FUNCTEST(nam, rout)  \
        if (strcmp(nam, pfunnam) == 0) \
            return rout(argc,argv);

/* PROGRAM: PRODSP
 * 
 *   This is the interface to all C routines that 
 *   Progress has associated ’call’ statements to. 
 */

long
PRODSP(pfunnam, argc, argv)

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

{
/* Interface to installation test */
    FUNCTEST( "SUBVRD", subvrd)
    FUNCTEST( "SUBVWT", subvwt)
    FUNCTEST( "SUBFRD", subfrd) 
    FUNCTEST( "SUBFWT", subfwt)
    FUNCTEST( "SUBFIX", subfix)
    FUNCTEST( "SUBVIX", subvix) 
    FUNCTEST( "SUBARG", subarg) 
    FUNCTEST( "SUBCLR", subclr) 
    FUNCTEST( "SUBCLS", subcls) 
    FUNCTEST( "SUBINT", subint)
/* Interface to ’screen’ examples */
    FUNCTEST ("EXAMPLE1", example1);
    FUNCTEST ("EXAMPLE2", example2);
/* Interface to ’tank’ example  */
    FUNCTEST ("AVCALC", hlvcalc);

    return 1;
} 

The following example is the front end to the sample test application:

hldemo.p
run loaddb.p.

input from terminal.
output to terminal.
define var answer as char format "9".
define var choice as char init "1,2,3,4".
define var last1 as log init yes.
define var last2 as log init yes.

form   skip(4)
       space (4)
         "  1  -   Installation Test" skip(1) space(4)
         "  2  -   TANK Capacity Calculation demo  "  skip(1) space(4)
         "  3  -   Screen raw/cooked demo " skip (1)   space(4)
         "  4  -   Exit Session" skip(2) space(4)
         " Enter example selection ===> "  answer no-label
              with centered title " EXAMPLE MENU " frame example.

form last1 last2 with frame lastcheck.
repeat.
  hide all.
  update answer auto-return
  validate(lookup(answer,choice) <> 0,"Enter one of choices displayed.")
     with frame example.
  hide all.
if answer = "1" then
   do:
/*  Check to see if need to reinitialize database. */
    if last1 then
    do:
       last1 = yes.
       last2 = no.
       run initdb.p.
       hide all.
    end.
    last1 = yes.
    run hltest.p.
   end. 
   else if answer = "2" then
     do:
/*  Check to see if need to reinitialize database. */
      if last2 then
      do:
         last2 = yes.
         last1 = no.
         run initdb.p.
         hide all.
      end.
      last2 = yes.
      run hltank.p.
     end.
    else if answer = "3" then
          run hlscreen.p.
    else if answer = "4" then
          quit.

end.
hide all.
quit. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095