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

 
2.2.1 - Creating an external HTML


An external HTML can reside either on a source physical file, or on an IFS stream file. We shall come to this later on.

An external HTML in concepts is very similar to a display file, or - even better -to a printer file.

Obviously, an external HTML does not use any DDS syntax / keywords. The rule there is HTML syntax / tags.
However, there is something conceptually similar to DDS:

  • the external HTML must be made of sections, which in a sense look like DDS traditional record formats. A section is a piece of HTML that can be written out from the CGI program.
  • sections may contain output variables, the same as DDS output fields

The CGI program would

  1. load the external HTML (the same as opening a printer file)
  2. assign values to the output variables of a given section
  3. write out that HTML section
  4. continue in this way until the HTML response string (output buffer) is complete
  5. send the output buffer (response string) to the browser client.


  1.  Defining a section 
    Examples of sections could be:
    • starting html, starting body, defining title and headers
    • a table start
    • a table row
    • a table end
    • body and html end
    Section rules:
    1. A section is identified by a source record containing
      • /$section_name starting in column 1, where section_name can be up to 20 characters
        (prefix /$ is the standard one for section identification; however, the developer may define other prefixes).
        As an example, /$top identifies the beginning of section "top".
    2. The section which is issued as first must start as follow
      /$section_name
      Content-type: text/html
      <html>
      Please pay attention to the blank line just before the one containing <HTML>. If you miss it, the client browser may not interpret your HTML!

  2.  Defining output variables 
    You specify a variable in your HTML text by using the following syntax:
        /%variable_name%/
    where variable_name can be up to 30 non-case sensitive characters.
    Delimiters /% and %/ are the standard ones.
    However, the developer may decide to use his own delimiters.
    There is no naming convention for variables. For instance, they do not need to have the same name of their corresponding database fields, though if you do so you may improve understanding of your programs.

  3.  Example of an external HTML
    Please check out the external HTML of program HELLO.

  4.  Section & Variable delimiters
    1. Section name delimiters.
      A section is identified by the following sequence starting in column 1 of a dedicated line:
      xxxsection_nameyyy
      where
      • xxx is the section name starting delimiter (10 char max) that you would mention in the RPG program when calling subprocedure gethtml.
        The default section name starting delimiter is /$. This default section name starting delimiter may be omitted when calling subprocedure gethtml.
      • section_name is the name of the section (mandatory) that you would mention when calling subprocedure wrtsection. Section name must be an alphanumeric string up to 20 characters.
      • yyy is the section name ending delimiter (optional, 10 char max). If specified, you must mention it in the RPG program when calling subprocedure gethtml.
      Notes on section name delimiters
      1. Default section name starting delimiter /$ may cause problems when the external HTML is on the IFS. This is because character $ may not be correctly converted for the CGISRVPGM2 service program.
      2. We suggest you use the following:
        "<! -- Sec_" as section name starting delimiter
        " -->" as section name ending delimiter
        Example:
        <! -- Sec_top -->
        for section top.
        This approach defines the HTML section as a comment and is therefore transparent to the HTML editors.
    2. Variable name delimiters
      The default delimiters for a variable name are
            /% and %/
      User-defined delimiters can also be used, provided thay do not exceed 10 characters.
      Non-default variable delimiters must be specified as parameters to the QGetHtml procedure.

  5.  Service program specifications 
    The following restrictions apply:
    Description Maximum
    Source record length 240 bytes (228 bytes for source data)
    Number of records 32,764
    Number of unique substitution variables (each may appear multiple times in the source) 16,221
    Number of occurrences of substitution variables in the source file member 32,767
    Substitution variable name length 30 characters
    Substitution variable value 1,000 characters
    Substitution variables' delimiters length 10 characters
    Number of sections 200
    Section name length 20 characters
    Section name delimiters' length 10 characters



    Contact