- QClrHtmlBuffer
- Clear the HTML output buffer
Use this procedure to clear the HTML output buffer.
This may be needed every time the CGI has written one or more sections to the HTML output buffer,
and the need exists to reuse the HTML buffer.
No parameter is needed.
Example:
... ... ...
SPECIAL-NAMES.
copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
... ... ...
* Clear the HTML output buffer
call 'QCLRHTMLBUFFER'. |
- QWrtHtmlToStmf
- Write HTML to a stream file
There might be cases where one wants to generate some HTML but,
instead of sending it to the client browser, would rather save it on a stream file.
Such pages are called dynastatic pages.
Usually this is done to provide a regularly updated "static" page made available
under WEB. An example could be that of a Stock Exchange status.
Usually this is done through batch jobs either repeating the process cycle
after a given interval time, or launched from some event, such as a database trigger.
After performing this function, the program would usually clear the HTML buffer
using procedure QCLRHTMLBUFFER.
Activation group *new is mandatory for programs using this procedure.
The user profile running the program must have appropriate authorities
over the directory of the stream file and over the stream file itself
if already existing.
The following parameters are passed:
- numeric return code; contains 0 if the operation was successful
- path and name of the stream file to be created/updated (char 1024)
- (optional) numeric code page of the stream file to be created
Example for creating/updating an HTML stream file
"/cgicbldev2/dynastatic/lottery.html"
... ... ...
SPECIAL-NAMES.
copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
... ... ...
* Variables for QWrtHtmlToStmf procedure
05 stmf PIC X(1024).
05 codePage PIC S9(9) comp-4 value 819.
05 retcode PIC S9(9) comp-4.
... ... ...
* Write several HTML sections
... ... ...
* Write the output buffer to the stream file
move '/cgicbldev2/dynastatic/lottery.html' to stmf
call 'QWRTHTMLTOSTMF' using stmf codePage
returning into retcode.
* Clear the output buffer
call 'QCLRHTMLBUFFER'. |
For an example of a program generating a dynastatic page,
see the COBOL source of program HTMLTOSTMF.
- QAppHtmlToStmf
- Append HTML to a stream file
Use this procedure to append the HTML buffer to an existing stream file.
After performing this function, the program would usually clear the HTML buffer
using procedure QCLRHTMLBUFFER.
Activation group *new is mandatory for programs using this procedure.
The user profile running the program must have appropriate authorities
over the directory of the stream file and over the stream file itself.
The following parameters are passed:
- numeric return code; contains 0 if the operation was successful;
contains -1 if the stream file could not be accessed.
- path and name of the stream file to be created/updated (char 1024)
Example of appending the HTML buffer to an existing stream file:
... ... ...
SPECIAL-NAMES.
copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
... ... ...
* Variables for QAppHtmlToStmf procedure
05 stmf PIC X(1024).
05 retcode PIC S9(9) comp-4.
... ... ...
* Write several HTML sections
... ... ...
* Append the output buffer to the stream file
move '/... ... ...' to stmf
call 'QAPPHTMLTOSTMF' using stmf
returning into retcode.
* Clear the output buffer
call 'QCLRHTMLBUFFER'. |
- QWrtSectionToStmf
- Write sections to a stream file
Use this procedure to generate, from your CGICBLDEV2 output buffer, a large stream file
(more than 16 MB).
In your program, instead of using procedure QWrtsection() to add contents to the output buffer,
you use procedure QWrtsectionToStmf which - after adding contents to the buffer - writes the buffer
to a stream file and clears the buffer, thus overcoming buffer size restrictions.
To close the stream file for good, you must send a *FINI section via QWrtsectionToStmf().
This procedure has four parameters:
- Section names - a string of blank separated names for the sections you want to output
(the same as in procedure QWrtsection() )
- Stream file path and name - this must be specified only in the first QWrtsectionToStmf(),
in order to create the stream file (if the stream file already exists, it is deleted)
- Data type - also this can be specified only in the first QWrtsectionToStmf() and can be either
- *TEXT (which means that data must be converted to the stream file CCSID), OR
- *BIN (which means that no data conversion should take place.
If omitted, *TEXT is assumed.
- Stream file CCSID - The CCSID of the receiving stream file. If omitted, CCSID 819 (US ASCII) is
assumed. It can be specified only in the first QWrtsectionToStmf().
Look at the following sample that creates stream file '/tmp/stripes.html':
PROCESS NOXREF APOST
ID DIVISION.
PROGRAM-ID. SECTTOSTMF.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
*=================================================================
DATA DIVISION.
FILE SECTION.
*=================================================================
WORKING-STORAGE SECTION.
*=================================================================
... ... ...
01 HTML-DATA.
* Variables to execute a command
05 rc PIC S9(9) comp-4.
05 cmd PIC X(2000).
* Variables for QUpdHtmlVar procedure
05 varnameout PIC X(30).
05 varvalout PIC X(1000).
* Variable for QWrtSection / QwrtSectionToStmf procedures
05 HtmlSects PIC X(1000).
* Variables for QWrtSectionToStmf procedure
05 stmf PIC X(1024).
05 codePage PIC S9(9) comp-4 value 819.
05 dataType PIC x(5) VALUE '*TEXT'.
05 retcode PIC S9(9) comp-4.
* Variables to perform loop B-PARA
05 WSA PIC S9(9) comp-4 VALUE 0.
05 WSA_END PIC S9(9) comp-4 VALUE 0.
05 edited-WSA PIC Z,ZZZ,ZZ9.
*=================================================================
* M A I N - L I N E
*=================================================================
... ... ...
PROCEDURE DIVISION.
... ... ...
*Create and fill the IFS stream file /tmp/stripes.html
* Clear the output buffer
call 'QCLRHTMLBUFFER'.
* Create the stream file and write initial HTML to it
move 'top tabstr' to HtmlSects.
move '/tmp/stripes.html' to stmf.
call 'QWRTSECTIONTOSTMF' using
HtmlSects
stmf
dataType
codePage.
* Loop writing HTML (stripes) to the stream file
move 'tabrow' to HtmlSects.
compute WSA_END = qty + 1.
perform B-PARA varying WSA from 1 by 1 until WSA=WSA_END.
* Write final HTML and close the stream file
move 'tabend bottom *fini' to HtmlSects.
call 'QWRTSECTIONTOSTMF' using
HtmlSects.
* Exit program
goback.
*----------------------------------
B-PARA.
move 'rownbr' to varnameout.
move WSA to edited-WSA.
move edited-WSA to varvalout.
call 'QUPDHTMLVAR' using varnameout varvalout.
call 'QWRTSECTIONTOSTMF' using
HtmlSects.
|
- QChkIFS
- Check an IFS object
Use this procedure to check if an IFS objects exists / can be accessed from the current user profile.
Activation group *new is mandatory for programs using this procedure.
The user profile running the program must have appropriate authorities
over the directory of the stream file and over the stream file itself.
The following parameters are passed:
- numeric return code; contains 0 if the operation was successful;
contains -1 if the stream file was not found or could not be accessed.
- path and name of the stream file to be checked (char 1024)
Example of checking an IFS object:
... ... ...
SPECIAL-NAMES.
copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
... ... ...
* Variables for QChkIFS procedure
05 IFSobj PIC X(1024).
05 retcode PIC S9(9) comp-4.
... ... ...
* Write several HTML sections
... ... ...
* Check an IFS object
move '/... ... ...' to IFSobj
call 'QCHKIFS' using IFSobj
returning into retcode. |