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

 
Examples

Library cgicbldev2 features some examples that might be helpful at the beginning. All the examples can be run. They include the ability to display the external HTML script and the source of the ILE-COBOL CGI program.

  1. Example of receiving and parsing an input string
    This example shows the use of
    • procedure QZhbGetInput to receive the input string
    • procedure QZhbGetVar to parse the input string into program variables
    • procedure QGetHtml to load the external HTML from a source file member
    • procedure QUpdHtmlVar to substitute output variables
    • procedure QWrtSection to write an HTML section in the output buffer and to send the output buffer
  2. Example 1 of listing a database file
    This example shows
  3. Example 2 of listing a database file
    Same as Example 1, but it loads the external HTML script from an IFS stream file, using procedure
    QGetHtmlIfs.

  4. Example 3 of listing a database file
    Same as Example 1, but it loads the external HTML script from multiple IFS stream files, using procedure
    QGetHtmlIfsMult.

  5. Populating a selection list
    Shows how to populate a selection list and how to position to a selected entry.

  6. Populating a table & managing multiple occurrences of an input variable
    Populating a table is very similar to populating a selection list.
    Receiving all the occurrences of an input variable requires both procedures
    QzhbGetVarCnt and QzhbGetVar.

  7. Example of creating and retrieving a cookie
    This example illustrates procedures
    QCrtCookie to create a cookie and QRtvCookie to retrieve a cookie.

  8. Example of issuing HTML messages
    This example shows how to write HTML messages using procedures
    QcfgMsgs, QclrMsgs, QaddMsg, QgetMsgCnt, and QwrtMsgs.

  9. Example of maintaining and retrieving page counts
    This example shows how to use procedure
    QcountP.

  10. Example of retrieving environment variables
    This example shows how to use procedure
    QgetEnv.

  11. Example of converting char to hex
    This example shows how to use procedure
    Qchar2Hex to convert a character string to an hexadecimal string.

  12. Example of converting hex to char
    This example shows how to use procedure
    Qhex2Char to convert an hexadecimal string to a character string.

  13. Example of generating a random integer
    This example shows how to use procedure
    QRandom to generate a random integer.
    It also takes afvantage of procedure QChkNbr to make sure that the user has entered a numeric value.

  14. Example of generating a random string
    This example shows how to use procedure
    QRandomString to generate a random string.
    It also takes advantage of procedure QChkNbr to make sure that the user has entered a numeric value for the string length.

  15. Example of writing a "dynastatic page" to an IFS stream file
    A "dynastatic" page usually is an HTML page that is written to a stream file, instead of being sent to a remote browser. Of course it could be any other type of data (a text, an image, a data stream, etc.) and its target may not be a WEB browser.
    Its size cannot exceed 16 MB.
    A dynastatic page is usually created by a batch program, which runs in given circumstances and provides a refresh to a static page.
    In this example, however, it's the browser user that, by pressing a special button, asks a CGI to refresh the dynastatic page. The CGI will then:
    • generate the output HTML for the dynastatic page in the output buffer
    • invoke procedure QWrtHtmlToStmf to copy the output buffer to the stream file (the dynastatic page)
    • invoke procedure QClrHtmlBuffer to clear the output buffer
    • create a new HTML page in the ouput buffer and send it to the remote browser.

  16. Example of writing to an IFS stream file a page larger than 16 MB
    When you need to write to a stream file a total amount of data that exceeds 16 MB, you may decide to use procedure QWrtSectionToStmf.
    This procedure allows to write to a stream file as many data strings as you need, provided that each single string does not exceed 16 MB by itself. Strings may contain output variables filled in with procedure QUpdHtmlVar. In this way you may build stream files larger than 16 MB.

    This example lets you select the size of a HTML stream file to be generated and provides the ability to display it from your WEB browser.
    Even a stream file larger than 16 MB can be generated on your request and your WEB browser will need some time to load it.




    Contact