Generating HTML from DP

Overview

One of the first considerations in generating HTML pages from a DP database is determining how many individual files there will be, and how the individual files will be named.

In this example, the file names will be based on the first five letters from field P1F3. In the discussion that follows, I will refer to these characters as "xxxxx" (without the quotes).

This report generates one file named xxxxx.HTM for a record in panel one, and files named xxxxxBpp.PL, xxxxxLpp.PL, and xxxxxPpp.HTM (where "pp" is the value in field P2F4) for each related record in panel two. Only part of the report is shown, which produces the xxxxx.HTM and xxxxxBpp.PL files.

  1 REPORT.BASED.ON.PANEL:1 
  2 NAME:~Generate all HTML and Perl scripts for database v2.0 (Use Alt-F7)~
  3 REPORT.MODE:TEXT
  4 REPORT.INDEX: 1 
  5 TEXT.LINES=0 TOP.MARGIN=0 BOTTOM.MARGIN=0 LEFT.MARGIN=0 
  6 REPORT.FORM:
  7 FIRST.PAGE.HEADER
  8 OTHER.PAGE.HEADER
  9 TWO.LEVEL.REPORT.HEADER
 10 REPORT.BODY
 11 ...
The ellipsis in line 11 is a part of the report that is not relevant to the production of HTML. In lines 12-20, the filename xxxxx\xxxxx.HTM is placed in rv5. Then, that file is opened to receive the report output (lines 21-23).
 12 SET.RV:3 FORMULA:~length[~  FIELD=P1F3 ~] cases~  CR
 13 ~  case cv<5 of~  CR
 14 ~    ~  FIELD=P1F3 ~ endof~  CR
 15 ~  default~  CR
 16 ~    substring[~  FIELD=P1F3 ~;1;5]~  CR
 17 ~endcases~ 
 18 FORMULA.END;
 19 SET.RV:5 FORMULA:~cat.t[rv3; '\'; rv3; '.HTM']~ 
 20 FORMULA.END;
 21 TURN.FILE.OFF
 22 BEGIN.WRITING.TO.FILENAME.IN.RV:5
 23 TURN.FILE.ON
Lines 24-58 generate the HTML file, which starts with the tag <HTML> and ends with the tag </HTML>. The subreport in lines 31-43 generates a hyperlink for each related record in panel two. Each generated anchor will look something like:
<A HREF="http://www.sanbachs.com/xxxxxPpp.HTM">...text from P2F5...</A>
assuming rv253 contains "www.sanbachs.com", which will cause the text from field P2F5 in each related record to be a hyperlink to the file named xxxxxPpp.HTM.
 24 ~<HTML>~  CR
 25 ~<HEAD>~  CR
 26 ~<TITLE>~  FIELD=P1F2;~A40;;T~ ~</TITLE>~  CR
 27 ~</HEAD>~  CR
 28  CR
 29 ~<H1>~  FIELD=P1F2;~A40;;T~ ~</H1>~  CR
 30 ~<HR>~ 
 31 SUBREPORT.THRU.DOOR:4 TO.PANEL:2
 32 FIRST.PAGE.HEADER
 33 OTHER.PAGE.HEADER
 34 TWO.LEVEL.REPORT.HEADER
 35 REPORT.BODY
 36 ~<A HREF="http://~ RV:253;~A50;;T~ ~/~ RV:3;~U5;;T~ ~P~  FIELD=P2F4;~GZ99;;B~ 
 37 ~.HTM">~  CR
 38  FIELD=P2F5;~A60;;T~ ~</A>~  CR
 39 ~<p>~ 
 40 TWO.LEVEL.FOOTER
 41 PAGE.FOOTER
 42 FINAL.FOOTER
 43 END.SUBREPORT.FOR.PANEL:2
 44 ~<HR>~  CR
 45 ~For assistance in using this database, contact~  CR
 46 ~<a href="http://www.sanbachs.com/">~  CR
 47 ~Sanbachs, LC</a> at:~  CR
 48 ~<ADDRESS>~  CR
 49 ~(801) 765-0166<BR>~  CR
 50 ~(801) 765-0191 (fax)<BR>~  CR
 51 ~<A HREF = "mailto:webmaster@sanbachs.com">~  CR
 52 ~webmaster@sanbachs.com</A>~  CR
 53 ~</ADDRESS>~  CR
 54  CR
 55 ~<h5 align=center>~  CR
 56 ~Copyright &#169; 1996, 1997 Sanbachs, LC ~  CR
 57 ~</h5>~  CR
 58 ~</HTML>~  CR
The subreport in lines 59-140 visits each related record in panel two, and, for each of them, generates the file named xxxxx\xxxxxBpp.PL, a Perl (programming language commonly used on the web) script. The Perl script produces an HTML page when it runs, and it is only that portion of the script that is shown in this example.
 59 SUBREPORT.THRU.DOOR:4 TO.PANEL:2
 60 FIRST.PAGE.HEADER
 61 OTHER.PAGE.HEADER
 62 TWO.LEVEL.REPORT.HEADER
 63 REPORT.BODY
 64 ...
Lines 65-78 place the filename xxxxx\xxxxxBpp.PL in rv5. I notice (now!) that rv3 would not need to be recomputed, as, in the database, field P2F3 is computed to be the same as field P1F3. Oh, well :-).
 65 SET.RV:3 FORMULA:~length[~  FIELD=P2F3 ~] cases~  CR
 66 ~  case cv<5 of~  CR
 67 ~    ~  FIELD=P2F3 ~ endof~  CR
 68 ~  default~  CR
 69 ~    substring[~  FIELD=P2F3 ~;1;5]~  CR
 70 ~endcases~ 
 71 FORMULA.END;
 72 SET.RV:1 FORMULA:~cat.t[rv3; 'B'; apply.format['G99';~  FIELD=P2F4 ~]; '.PL']~ 
 73  CR
 74 FORMULA.END;
 75 SET.RV:2 FORMULA:~cat.t[rv3; 'L'; apply.format['G99';~  FIELD=P2F4 ~]; '.PL']~ 
 76 FORMULA.END;
 77 SET.RV:5 FORMULA:~cat.t[rv3; '\'; rv1]~ 
 78 FORMULA.END;
The file is opened in lines 79-82. Line 80 shows a "progress" message on the screen.
 79 TURN.FILE.OFF
 80 RV:20;~A50A0~ 
 81 BEGIN.WRITING.TO.FILENAME.IN.RV:5
 82 TURN.FILE.ON
The HTML begins at line 83 with the <HTML> tag. Notice that the title of the HTML page comes from field P2F5, the same field used for the hyperlink generated in lines 36-38.
 83 ~<HTML>~  CR
 84 ~<HEAD>~  CR
 85 ~<TITLE>~  FIELD=P2F5;~A60;;T~ ~</TITLE>~  CR
 86 ~</HEAD>~  CR
 87 ~<BODY>~  CR
 88 ...
The bulk of the HTML is a "table" beginning with the <table...> tag of line 89, and ending with the </table> tag of line 130.
 89 ~<table border="1">~  CR
 90 ~<caption><H3>~  FIELD=P2F5;~A60;;T~ ~</H3></caption>~  CR
 91 ~<tr><td>~  CR
 92 ~(<A HREF="http://www.sanbachs.com/~ RV:3;~A5;;T~ 
 93 ~.HTM" target="_top">Back to Panel List</A>)~  CR
 94 ~<FORM ACTION="http://~ RV:252;~A50;;T~ ~/~ RV:1;~A12;;T~ ~" METHOD=POST>~  CR
 95 ~Navigating:~  CR
 96 ~<INPUT TYPE=SUBMIT NAME="_Lookup" VALUE="First Record">~  CR
 97 ~<INPUT TYPE=SUBMIT NAME="_Lookup" VALUE="Previous Record">~  CR
 98 ~<INPUT TYPE=SUBMIT NAME="_Lookup" VALUE="Next Record">~  CR
 99 ~<INPUT TYPE=SUBMIT NAME="_Lookup" VALUE="Last Record">~  CR
100 ~<br>Actions:~  CR
101 ~<INPUT TYPE=SUBMIT NAME="_Action" VALUE="Create a new record">~  CR
102 ~<INPUT TYPE=SUBMIT NAME="_Action" VALUE="Edit this record">~  CR
103 ~<INPUT TYPE=SUBMIT NAME="_Action" VALUE="Delete this record">~  CR
104 ~<tr><td>~  CR
105 ~<table>~  CR
106 SET.RV:4 FORMULA:~0~ 
107 FORMULA.END;
108 SUBREPORT.THRU.DOOR:7 TO.PANEL:3
109 FIRST.PAGE.HEADER
110 OTHER.PAGE.HEADER
111 TWO.LEVEL.REPORT.HEADER
112 ~rv30  -- Boolean: field is NOT a hidden field~ 
113 REPORT.BODY
114 SET.RV:9 FORMULA: FIELD=P3F12 
115 FORMULA.END;
116 SKIP.RECORD.ON.RV:9
117 SET.RV:4 FORMULA:~rv4+1~ 
118 FORMULA.END;
119 SET.RV:30 FORMULA: FIELD=P3F15 ~=' '~ 
120 FORMULA.END;
121 SKIP.RECORD.ON.RV:30
122 ~<tr><td align="right" valign="top"><strong>~  CR
123  FIELD=P3F8;~A60;;T~ ~:</strong>~  CR
124 ~</td><td>$_dp[~ RV:4;~GZZ9;;B~ ~]</td>~ 
125 TWO.LEVEL.FOOTER
126 PAGE.FOOTER
127 FINAL.FOOTER
128 END.SUBREPORT.FOR.PANEL:3
129 ...
130 ~</table>~  CR
131 ...
132 ~<h5 align=center>~  CR
133 ~Copyright &#169; 1996, 1997 Sanbachs, LC~  CR
134 ~</h5>~  CR
135 ~</BODY>~  CR
136 ~</HTML>~  CR
137 TWO.LEVEL.FOOTER
138 PAGE.FOOTER
139 FINAL.FOOTER
140 END.SUBREPORT.FOR.PANEL:2
141 ...
142 TWO.LEVEL.FOOTER
143 PAGE.FOOTER
144 FINAL.FOOTER
145 REPORT.END;
146 
147 

Back to Sanbachs Home Page

Last updated: March 21, 1997.

Copyright © 1997 Sanbachs, LC.