|
This page shows how to
We recommend you use
Use subprocedure
1) getHtml
2) getHtmlifs
See the example in CGI
TEMPLATE4. Note that the directory to be specified as a parameter of the gethtmlifs procedure is the real directory path, not the alias mentioned in a HTTP pass directive. The recommendation is -in any case- not to use for the IFS html code directories accessed also by the HTTP server. 3) getHtmlifsMult This subprocedures allows to load into memory multiple externally defined html files. All the sections and records in all the files are read into dynamic storage as though they resided in a single file. If a section name appears more than once, only the first occurrence is used. This feature allows to maintain as separate HTML files frequently used pieces of HTML code, such as headers, footers, navigation bars, etc.. In several cases, breaking html code into separate modules may greatly reduce both development and maintenance times.
See the example in CGI
TEMPLATE5.
Note 1. Subprocedures getHtmlifs and getHtmlifsMult can also load HTML source members as part of the /QSYS.LIB/... directory. See the following example:
Note 2. When using getHtmlifs or getHtmlifsMult subprocedure, make sure that the IFS files containing the external HTML code can be read from the HTTP server user profile QTMHHTP1 (the one adopted when running CGI). This can be done in one of the following ways (in the examples below, we assume that QPGMR owns the files, but this is not relevant at all):
or
Examples for user-defined delimiters (see also this page). First example:
Second example:
This must be done using subprocedure updHtmlVar. This subprocedure assigns a value to all the instances of a given html variable name. Note 3. The value to be assigned must be a character string (numeric fields must be converted or edited to character strings, see examples number 4 and 5).
Examples:
In this subprocedure, instead of passing the name or the value of the substituting variable, you will pass a pointer to it and its length.
Examples:
This must be done using subprocedure wrtsection. One can write one or multiple sections in a single call. Important. Once all sections have been written, do not forget to send the output buffer to the client. This must be done by writing a pseudo section named *fini. Example:
Note 4. Section names are not case sensitive.
A section name is a 50 char max alfanumeric string. Only english letters are supported. Note 5. Subprocedure wrtSection supports two optional parameters:
Note 6. WARNING - wrtSection(*fini) will not perform and return an error
message in file CGIDEBUG if the outbut buffer size exceeds 16 Mb.
Subprocedure wrtNoSection writes data for the browser without using substitution variables or sections. This subprocedure can be used when a large block of data is to written. This is more likely to happen when writing non-textual data such as images. The following example shows how to read an external IFS file (an HTML page, an image, or what you need) and how to insert it into the CGI output buffer:
WARNING - Be careful not to exceed the 16 Mb limit of the output buffer. If that limit is exceeded, wrtSection(*fini) will fail. Subprocedure clrHtmlBuffer clears any HTML output that has been buffered but has neither been sent to the browser nor written into a stream file. This is useful when program logic dictates you need to output something other than what has already been buffered.
Subprocedure getHtmlBytesBuffered Could be useful to stop creating an output page when its size exceeds a reasonable limit.
Subprocedure getHtmlBufferP
Subprocedure crtTagOpt for use within a <select ...> list.
We have a program that demonstrates the use of subprocedure CrtTagOpt:
|