Submitted by Bent Rønne on Sat, 07/01/2006 - 00:00
Forums

In this sample I split the logic and the design into two files (.ASP and .HTML). I'm using the "Pre-compile time Include with tags" technique in the sample. This will make the ASP source code much easier to understand and the HTML include file will only hold the presentation.

The following list program is written in fixed RPGLE and it loops through a file called Product. All records are putted into a HTML table described in the included file.

The HTML file looks like:

   <!--#tag="Init"-->
  <html>
    <head>
     <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
     <link rel="stylesheet" type="text/css" href="/System/Styles/IceBreak.css"/>
    </head> 

    <!--#tag="ListHeader"-->
   <body>
     <form method="POST" action="#" id="form1" name="form1">
        <fieldset><legend>Work with Products</legend>
          <table class="ListHead">
           <thead>
              <tr class="ListHead">
                <th></th>
                <th>Product<br>ID</th>
               <th align="left">Description</th>
                <th>Manufacturer<br>ID</th>
                <th align="right">Price</th>
               <th align="right">Stock<br>Count</th>
                <th>Stock<br>Date</th>
             </tr>
            </thead>
           <!--#tag="ListDetail"-->
           <tr class="ListDetail">
              <td><a title="Detail" href="ex19EdtPrd.asp?ProdKey=<%=%char(ProdKey)%>"><img src="/System/Images/plus2d.jpg" border="0"></a></td>
              <td ><% = ProdId %> </td>
              <td ><% = Desc %> </td>
              <td ><% = ManuID  %> </td>
              <td align="right"><% = %Editc(Price : 'N')  %> </td>
              <td align="right"><% = %Editc(StockCnt : 'N')  %> </td>
             <td><% = %char(StockDate: *ISO)  %> </td>
           </tr>
          <!--#tag="Exit"-->
         </table>
       </fieldset>
        <input type="button" onclick="window.open('ex19EdtPrd.asp', '_parent');" value="Create" name="Func">
       <input type="button" onclick="history.back();" value="Back" name="Back">
     </form>
    </body>
  </html> 

And the .ASP file looks like: 

   <%
  *' ------------------------------------------------------------------------
  *' Company . . . . :  Agentdata, Denmark
  *' Design  . . . . :  Bent Ronne
   *' Function  . . . :  List records in a web list
   * '
  *' Created . . . . :  11.11.11 12:12:12
   *'
   *' ------------------------------------------------------------------------
 H*Keywords+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Comments++++++++++++
 H DecEdit(*JOBRUN)

  F*Filename+IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++++++++Comments++++++++++++
 FProduct   if A E           K disk     
  
  C*LN01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq....Comments++++++++++++ 

  C                   exsr      init
 C     *loval        setll     ProductR
 C                   read      ProductR                               80
  C     *in80         doweq     *off
  C                   exsr      ListDetail
 C                   read      ProductR                               80
  C                   enddo               

 C                   exsr      exit

  /* ------------------------------------------------------------------------
     Init set up the HTML header incl. stylesheets  and scripts
      ------------------------------------------------------------------------ */
  C     Init          Begsr    
  %><!--#include file="Tutorials/ex19WrkPrd.htm"  tag="init"--><%
  %><!--#include file="Tutorials/ex19WrkPrd.htm"  tag="ListHeader"--><%
  C                   endsr


  * ------------------------------------------------------------------------
   * Write the line
   * ------------------------------------------------------------------------
  C     ListDetail    Begsr    
  %><!--#include file="Tutorials/ex19WrkPrd.htm"  tag="ListDetail"--><%
  C                   endsr  

  * ------------------------------------------------------------------------
   * Done
   * ------------------------------------------------------------------------
  C     exit          Begsr    
  %><!--#include file="Tutorials/ex19WrkPrd.htm"  tag="exit"--><%
  C                   move      *on           *inlr
  C                   return
  C                   EndSr
 %> 

 

  C     ListDetail    Begsr    
  %><!--#include file="Tutorials/ex19WrkPrd.htm"  tag="ListDetail"--><%
  C                   endsr  

Interesting approach.
How does RPG compiler know what to do with a %><!-- tag --><% ?
Why does the .asp file look suspiciously like RPG?
Hmmm, maybe we are not even dealing with an RPG compiler here?
Do you require Apache sever and/or dedicated application server?


By comparison the CGIDEV2 (as well as Cozzi & Stone) method would look something like this:

   c     eval      IfsMultIndicators = gethtmlifsmult('/CgidevExt/salesReport1ifs.html':'<as400>')
  C     callp     updHTMLvar('Region' :myvariable)
  c     callp     wrtsection('TableDetail') 

ref: http://tinyurl.com/jf4jf

Actually we are talking about a pre-compiler for RPGLE and COBOL. The IceBreak pre-compiler creates a new RPGLE or COBOL behind the scene where special character strings like the <% and %> are converted into to IceBreak build in functions.

So, it is true that we are dealing with real OS400 compiled programs running native OS400 and through the genuine OS400 native application server IceBreak!

Bent

I think RPGsp has the same idea but flips it around.... Add the RPG to your HTML code, sort of like PHP approach but much more goofy looking. (Reminds me of that old commercial... "You got chocolate in my peanut butter, no you got peanut butter in my chocolate").

What is amazing , is the lengths we will go not to have to learn a new language.

I’m sure you agree when I say - you have to learn HTML if you like your application on the WEB!

The IceBreak Application server and your own program are all that runs at runtime – nothing else! IceBreak is the dedicated server needed and it runs directly in OS400. If you use WRKACTJOB you will see a Subsystem called ICEBREAK. Underneath you will see you own program running with OS400 joblogs, open files etc.

Your program sources are placed in the IFS together with HTML. You can mix RPG/COBOL and HTML in the same source or as stated in this thread separated into different files.

You can use any kind of editors: Notepad, Frontpage, WebSphere, HTML-kit, UltraEdit, PSPad and even MAC and EDTF (from 5250).

You do NOT need any Microsoft licenses.