Skip to main content development
   toolset
 
  Easy400   |       iSeries home
Public-Source
 
Introduction
Tutorial
Examples
FAQ
Index
Download
 
 

 
2.2.4 - Writing sections


Once all the output variables of a section have been substituted with their values, the section can be written to the HTML output buffer.

 QWrtSection 
This is done calling procedure QWRTSECTION.
The following parameters are passed:

  1. names of the sections to be written, separated by blanks (char 1000)
  2. (optional) no new-line indicator.
    When passed and containing '1', a newline character (x'15') is not appended to each html output line. This is useful when binary data are being sent to the browser.

Example of writing section /$top
            ...         ...         ...
       SPECIAL-NAMES.
             copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
              ...         ...         ...
      * Variables for QWrtSection procedure
           05     HtmlSects           PIC  X(1000).
           05     nonewline           PIC  1.
            ...         ...         ...
      * Write section "top"
           move 'top' to HtmlSects
           call 'QWRTSECTION' using HtmlSects.

Example of writing sections /$top, /$body, and /$end all together:
            ...         ...         ...
       SPECIAL-NAMES.
             copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
              ...         ...         ...
      * Variables for QWrtSection procedure
           05     HtmlSects           PIC  X(1000).
           05     nonewline           PIC  1.
            ...         ...         ...
      * Write sections "top", "body", and "end"
           move 'top body end' to HtmlSects
           call 'QWRTSECTION' using HtmlSects.

 Sending the output buffer .
After the last section has been written and before the CGI returns, the output buffer must be sent to the client browser.
If the CGI returns without sending the output buffer, an exception (error 500) is displayed by the browser.

In order to send the output buffer, use procedure WRTSECTION specifying, as the name of the section to be written, the pseudo-section *fini.
Of course, this section does not exist in your external HTML.
            ...         ...         ...
       SPECIAL-NAMES.
             copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
              ...         ...         ...
      * Variables for QWrtSection procedure
           05     HtmlSects           PIC  X(1000).
           05     nonewline           PIC  1.
            ...         ...         ...
      * Write sections "top", "body", "end", and send the output buffer
           move 'top body end *fini' to HtmlSects
           call 'QWRTSECTION' using HtmlSects.



    Contact