****************************************************************                              
      * Defined Constants                                            *                              
      ****************************************************************                              
      * #setWriteTo Constants                                                                       
     D W_STDOUT        C                   CONST(0)                             StOut               
     D W_FILE          C                   CONST(1)                             File                
     D W_STDFILE       C                   CONST(2)                             StdOut and File     
      *                                                                                             
      * #setDataCase Constants                                                                      
     D AS_IS           C                   CONST(0)                             "As Is"             
     D UPPER           C                   CONST(1)                             Convert to Upper    
     D LOWER           C                   CONST(2)                             Convert to Lower    
      *                                                                                             
      * General Constants                                                                           
     D BUFFER_SIZE     C                   CONST(65535)                         Buffer Size         
      *//////////////////////////////////////////////////////////////*                              
      * #setPath - Set the Template Path                             *                              
      *                                                              *                              
      * Notes: This function is used to set the working path to      *                              
      * find templates in.  This function only needs to be called    *                              
      * to change the path from the default before the first call to *                              
      * #loadTemplate or #writeTemplate.                             *                              
      *                                                              *                              
      * The template default path is changed using the SETPATH       *                              
      * command specifying a type of *TEMPLATE.  The template        *                              
      * default path can be viewed in the TEMPLATE data area in      *                              
      * the production library.                                      *                              
      *                                                              *                              
      * InPath (Optional) - The path to use.                         *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setPath        PR                                                                           
     D  InPath                      256    Const Varying Options(*NOPASS)                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setOutPath - Set Output File Path                           *                              
      *                                                              *                              
      * Notes: This function is used to set the working path to      *                              
      * store output files.  This function only needs to be called   *                              
      * to change the path from the default before the first call to *                              
      * #openOutFile.                                                *                              
      *                                                              *                              
      * The output default path is changed using the SETPATH         *                              
      * command specifying the *OUTPATH type.  This default can be   *                              
      * viewed in the OUTPATH data area in the production library.   *                              
      *                                                              *                              
      * InPath (Optional) - The path to use.                         *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setOutPath     PR                                                                           
     D  InPath                      256    Const Varying Options(*NOPASS)                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setImmediate - Set the Write Immediate Flag                 *                              
      *                                                              *                              
      * Notes: This flag is used to tell the system to write data    *                              
      * immediately (to StdOut or File or Both) or to store the      *                              
      * data in a buffer until the #cleanup subprocedure is called   *                              
      * or the buffer is filled.                                     *                              
      *                                                              *                              
      * InImmediate (Input) - Immediate Flag                         *                              
      *   *OFF - Write to Buffer (Default)                           *                              
      *   *ON - Write Immediately to StdOut                          *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setImmediate   PR                                                                           
     D  InImmediate                    N   Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setWriteTo - Set the Write To Location                      *                              
      *                                                              *                              
      * Notes: This flag is used to tell the system where it will    *                              
      * write data.  The current options are to Standard Output,     *                              
      * a Stream File, or Both.                                      *                              
      *                                                              *                              
      * The default value is Standard Output (StdOut).  If the       *                              
      * data is to be written to a file the #openFile function       *                              
      * must be called prior to writing any data.                    *                              
      *                                                              *                              
      * InWriteTo (Input) - Write Location Value                     *                              
      *   W_STDOUT - StdOut Only (Default)                           *                              
      *   W_FILE - File                                              *                              
      *   W_STDFILE - StdOut and File                                *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setWriteTo     PR                                                                           
     D  InWriteTo                    10i 0 Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setAppend - Set Append Attribute for Writing Data to        *                              
      *              Stream File                                     *                              
      *                                                              *                              
      * InAppend (Input) - Append Flag                               *                              
      *   *OFF - Do not append data (Default)                        *                              
      *   *ON - Append data                                          *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setAppend      PR                                                                           
     D  InAppend                       N   Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setPublic - Set Public Attribute for Created Stream File    *                              
      *                                                              *                              
      * InPublic (Input) - Public Flag                               *                              
      *   *OFF - Do not give *PUBLIC authority to file               *                              
      *   *ON - Give *PUBLIC authority to file                       *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setPublic      PR                                                                           
     D  InPublic                       N   Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setCodePage - Set Code Page for Created Stream File         *                              
      *                                                              *                              
      * InCodePage (Input) - Code page for stream file if file       *                              
      *                      is created (Default = 819)              *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setCodePage    PR                                                                           
     D  InCodePage                   10i 0 Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setCCSIDStdOut - Set CCSID of Output written to StdOut      *                              
      *                                                              *                              
      * InCCSID (Input) - CCSID of the output written to StdOut.     *                              
      *                   Set this to zero for no translation.       *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setCCSIDStdOut...                                                                           
     D                 PR                                                                           
     D  InCCSID                      10i 0 Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setSecDelim - Set Section Delimiter                         *                              
      *                                                              *                              
      * InSecDelim (Input) - Section delimiter that is used in       *                              
      *                      template files (Default = "/$")         *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setSecDelim    PR                                                                           
     D  InSecDelim                   64    Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #setDataCase - Set Default Case for Data Returned from       *                              
      *                #getData                                      *                              
      *                                                              *                              
      * InCase (Input) - Default setting for case of data returned   *                              
      *                  using #getData                              *                              
      *   AS_IS - Data is returned "as is" (Default)                 *                              
      *   UPPER - Data is returned in all upper case                 *                              
      *   LOWER - Data is returned in all lower case                 *                              
      *//////////////////////////////////////////////////////////////*                              
     D #setDataCase    PR                                                                           
     D  InCase                       10i 0 Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * (#getData) Get Form Field Data                               *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * Field name IS case sensitive.                                *                              
      *                                                              *                              
      * InField (Input) - Name of field of data to get               *                              
      * InOccur (Optional) - Occurance of field to get               *                              
      * InCase (Optional) - Case of data to be returned.  This will  *                              
      *                     override the default setting.            *                              
      *   AS_IS - Data is returned "as is" (Default)                 *                              
      *   UPPER - Data is returned in all upper case                 *                              
      *   LOWER - Data is returned in all lower case                 *                              
      * Returns - Value of field                                     *                              
      *//////////////////////////////////////////////////////////////*                              
     D #getData        PR         65535    Varying                                                  
     D  InField                      64    Const                                                    
     D  InOccur                      10i 0 Const Options(*NOPASS)                                   
     D  InCase                       10i 0 Const Options(*NOPASS)                                   
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #getCookie - Retrieve a cookie value                         *                              
      *                                                              *                              
      * CookieName (Input) - Name of cookie to retrieve value for    *                              
      * Index (Optional) - Index of cookie to get                    *                              
      * Returns - Value of cookie                                    *                              
      *//////////////////////////////////////////////////////////////*                              
     D #getCookie      PR         65535    Varying                                                  
     D  CookieName                   64    Const                                                    
     D  Index                        10I 0 Const Options(*NOPASS)                                   
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #buildCookie - Build a Cookie                                *                              
      *                                                              *                              
      * CookieName (Input) - Name of cookie to build                 *                              
      * CookieValue (Input) - Value assigned to cookie (unescaped)   *                              
      * NumHours (Optional) - Number of hours until cookie expires   *                              
      *                       If omitted, the cookie will be valid   *                              
      *                       for the browser session only.          *                              
      * Path (Optional) - Path cookie is valid for                   *                              
      * Domain (Optional) - Domain cookie is good for                *                              
      * Secure (Optional) - Secure Cookie (Default *OFF)             *                              
      * Returns - String containing cookie header                    *                              
      *//////////////////////////////////////////////////////////////*                              
     D #buildCookie    PR         65535    Varying                                                  
     D  CookieName                   64    Const                                                    
     D  CookieValue               65535    Const Varying                                            
     D  NumHours                     10I 0 Const Options(*NOPASS)                                   
     D  Path                        128    Const Options(*NOPASS)                                   
     D  Domain                      128    Const Options(*NOPASS)                                   
     D  Secure                         N   Const Options(*NOPASS)                                   
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #loadTemplate - Load Template                                *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * If the #wrtSection function is called prior to any  calls    *                              
      * to #loadSection the entire template will be written.         *                              
      *                                                              *                              
      * Path (Input) - Path of template to load.  If the path is     *                              
      *                preceeded by a "/" it will be treated as a    *                              
      *                qualified path.  If not, the default          *                              
      *                template path will be appended to the front   *                              
      *                of the path in this parameter.                *                              
      * Section (Optional) - Section to immediatley load             *                              
      *//////////////////////////////////////////////////////////////*                              
     D #loadTemplate   PR                                                                           
     D  Path                        256    Const                                                    
     D  Section                      64    Const Varying Options(*NOPASS)                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #loadSection - Load Section Data                             *                              
      *                                                              *                              
      * Section (Input) - The section to load                        *                              
      *//////////////////////////////////////////////////////////////*                              
     D #loadSection    PR                                                                           
     D  Section                      64    Const Varying                                            
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #replaceData - Replace Values in Loaded Section              *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * All values ARE case sensitive.                               *                              
      *                                                              *                              
      * From (Input) - From value                                    *                              
      * To (Input) - Replacemanet value                              *                              
      * Trim (Optional) - Trim replacement value (default *ON)       *                              
      *//////////////////////////////////////////////////////////////*                              
     D #replaceData    PR                                                                           
     D  From                       4096    Const Varying                                            
     D  To                         4096    Const Varying                                            
     D  Trim                           N   Const Options(*NOPASS)                                   
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #writeSection - Write Loaded Section                         *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function will write the currently loaded section        *                              
      * with any replaced data to output.  It will then reset        *                              
      * the currently loaded section.                                *                              
      *//////////////////////////////////////////////////////////////*                              
     D #writeSection   PR                                                                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #writeThisSec - Immediately Write the Specified Section      *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This will NOT change the contents of the current loaded      *                              
      * section.                                                     *                              
      *                                                              *                              
      * Section (Input) - The section to write                       *                              
      *//////////////////////////////////////////////////////////////*                              
     D #writeThisSec   PR                                                                           
     D  Section                      64    Const Varying                                            
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #writeTemplate - Immediately Write Specified Template        *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This will NOT change the contents of the current loaded      *                              
      * section.  This function will read through the entire         *                              
      * template file and write it to Standard Output and/or         *                              
      * the current open output file.                                *                              
      *                                                              *                              
      * Path (Input) - Path of template to load.  If the path is     *                              
      *                preceeded by a "/" it will be treated as a    *                              
      *                qualified path.  If not, the default          *                              
      *                template path will be appended to the front   *                              
      *                of the path in this parameter.                *                              
      *//////////////////////////////////////////////////////////////*                              
     D #writeTemplate  PR                                                                           
     D  Path                        256    Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #openOutFile - Open File for Output                          *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function must be called prior to calling #wrtSection    *                              
      * with the Write To flag is set to W_FILE or W_STDFILE.        *                              
      *                                                              *                              
      * Use the #setAppend and #setPublic and #setCodePage functions *                              
      * to change the defaults for file creation attributes.         *                              
      *                                                              *                              
      * Path (Input) - Path of file to receive output.  If the path  *                              
      *                is preceeded by a "/" it will be treated as a *                              
      *                qualified path.  If not, the default          *                              
      *                template path will be appended to the front   *                              
      *                of the path in this parameter.                *                              
      *//////////////////////////////////////////////////////////////*                              
     D #openOutFile    PR                                                                           
     D  Path                        256    Const                                                    
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #closeOutFile - Close File for Output                        *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * If the Write Immediate flag is set to *ON and the write      *                              
      * flag is set to W_FILE or W_STDFILE this function can be      *                              
      * called unless the #cleanup function is called at the         *                              
      * end of the program.                                          *                              
      *                                                              *                              
      * Calling the #cleanup function will automatically close       *                              
      * the output file and this function would not need to be       *                              
      * called.                                                      *                              
      *//////////////////////////////////////////////////////////////*                              
     D #closeOutFile   PR                                                                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #startup - Perform Startup                                   *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function should be called at the start of every         *                              
      * to ensure that the temporary buffers are cleared and all     *                              
      * flags and work variables are set back to their defaults.     *                              
      *//////////////////////////////////////////////////////////////*                              
     D #startup        PR                                                                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #cleanup - Perform Cleanup                                   *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function should be called at the end of every program.  *                              
      * If unwritten data exists in storage it will be written.      *                              
      * If a file is open for output it will be closed.              *                              
      * Reset all flags and work variables.                          *                              
      *//////////////////////////////////////////////////////////////*                              
     D #cleanup        PR                                                                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #writeToBuffer - Write data to buffer                        *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #writeToBuffer  PR                                                                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #flushBuffer - Flush the buffer                              *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #flushBuffer    PR                                                                           
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #writeToFile - Write Data to File                            *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #writeToFile    PR                                                                           
     D  InData                    65535    Const Varying                                            
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #sendError - Send an Error                                   *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #sendError      PR                                                                           
     D  InError                   65535    Const Varying                                            
      *//////////////////////////////////////////////////////////////*                              
      * #getPath - Get Default Path                                  *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #getPath        PR           256    Varying                                                  
     D  InType                       10    Const Options(*NOPASS)                                   
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #getQPath - Get Qualified Path                               *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #getQPath       PR           256    Varying                                                  
     D  InPath                      256    Const Varying Options(*NOPASS)                           
     D  InType                       10    Const Options(*NOPASS)                                   
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #getSecDelim - Get Default Section Delimiter                 *                              
      *                                                              *                              
      * Notes:                                                       *                              
      * This function is used internally and not exported.           *                              
      *//////////////////////////////////////////////////////////////*                              
     D #getSecDelim    PR            64    Varying                                                  
      *                                                                                             
      *//////////////////////////////////////////////////////////////*                              
      * #getCaller - Get Name of Calling Program                     *                              
      *//////////////////////////////////////////////////////////////*                              
     D #getCaller      PR            20    Varying                                                  
      *