Generating HTML Output

This section provides an overview of HTML output and discusses how to:

  • Produce HTML output.

  • Use -PRINTER:EH.

  • Set HTML attributes under -PRINTER:EH.

  • Use -PRINTER:HT.

  • Burst reports.

  • Set attributes with HTML procedures.

  • Use additional HTML procedures.

  • Set output file types.

  • Test HTML output.

When an SQR program generates HTML output, that output contains HTML tags. An HTML tag is a character sequence that defines how information appears in a web browser.

Typically, HTML output looks like this:

<HTML><HEAD><TITLE>myreport.lis</TITLE></HEAD><BODY>

This code is only a portion of the HTML output that SQR generates. The tags that it contains indicate the start and end points of HTML formatting.

For example, in the code example, the <HTML> tag identifies the output that follows as HTML output. The <TITLE> and </TITLE> tags enclose the report title, in this case, myreport.lis. The <BODY> tag indicates that the information following it makes up the body of the report.

You can produce HTML output from an SQR program by using one of four methods, each of which provides a different level of HTML features:

  • Running an unmodified SQR program with the -PRINTER:EH command-line flag makes the HTML 3.0 or 3.2 output viewable in a web browser.

  • Running an unmodified SQR program with the -PRINTER:HT command-line flag makes the HTML 2.0 output viewable in a web browser.

  • Using two HTML procedures, html_set_head_tags and html_set_body_attributes, enables you to define a title and background image for HTML output.

    With this method, you must still use the -PRINTER:HT command-line flag.

  • Using additional HTML procedures produces output with a full set of HTML features, including lists, tables, and links.

    With this method, you must still use the -PRINTER:HT command-line flag.

The procedures that are used in the last two options are contained in a file called html.inc. To use HTML procedures, the SQR program must include this command:

#include 'html.inc'

The HTML.INC file is located in the SAMPLE (or SAMPLEW) directory. Use the -I command-line flag to specify its path.

You can generate enhanced HTML output from an SQR program by using the -PRINTER:EH command-line flag. Output that contains HTML formatting tags is produced. All output is displayed as fully formatted HTML 3.0 or 3.2 text. You can generate high-quality HTML from SQR programs by using -PRINTER:EH to issue a command like this:

sqrw myreport.sqr sammy/baker@rome -PRINTER:EH

You can control the version of HTML that is used by editing the FullHTML enhanced HTML parameter in the PSSQR.INI file. Set FullHTML to be equal to TRUE for HTML 3.2 or FALSE for HTML 3.0. Adjust this setting based on the level of HTML that your web browser supports. The -PRINTER:EH default output is HTML 3.0.

If you have existing .spf files for which you want to generate enhanced HTML output, you do not need to rerun your SQR program. You can invoke SQR Print (with SQRP or SQRWP, depending on your platform) to generate enhanced HTML from .spf files by using a command like this:

sqrwp myreport.spf -PRINTER:EH

From within the SQR Viewer, you can also generate the same high-quality HTML by selecting File, Save as HTML. The HTML level output from the SQR Viewer is also determined by the PSSQR.INI file settings and has the same default value.

You can also generate enhanced HTML files with precompiled SQR program files (.sqt files). Run the .sqt file against SQR Execute with a command like this:

sqrwt myreport.sqt sammy/baker@rome -PRINTER:EH

As is true when running any .sqt file, you can run it against SQR (or sqrw on Microsoft Windows platforms) by including the -RT flag. To generate enhanced HTML, use the -PRINTER:EH flag in the command:

sqrw myreport.sqr sammy/baker@rome -RT -PRINTER:EH

The sample program ex7a.sqr produces a simple master and detail report. By running it with -PRINTER:EH, you can produce HTML output. A left frame is produced with links to each page of the report. The right frame features a navigation bar that appears at the top of every page in the report. The navigation bar enables you to move to the first or last page or to move one page forward or backward from your relative page viewing position.

With -PRINTER:EH, you can also use additional flags to modify the output, such as:

  • -EH_CSV

    This flag creates an additional output file in comma separated values (CSV) format.

  • -EH_CSV:file

    This flag associates the CSV icon with the specified file.

  • -EH_Icons:dir

    This flag specifies the directory in which the HTML should find the referenced icons.

  • -EH_Scale:{nn}

    This flag sets the scaling factor from 50 to 200.

These flags work only with -PRINTER:EH.

In certain cases, you may want additional control over the enhanced HTML code that is generated with -PRINTER:EH. SQR supports extensions that enable you to control the generated HTML by specifying titles, background colors and images, links, text colors, and more.

Specifying HTML Titles

The HTML page title normally appears on the caption bar of the browser window and is also used when you are creating a bookmark for the page. It is placed between the <TITLE> and </TITLE> HTML tags. Specify the title of the HTML page by using the %%Title extension at the beginning of the SQR program by entering:

Print-Direct Printer=html '%%Title Monthly Sales'

Specifying Background Colors

Specify a background color for the pages that are generated with -PRINTER:EH by using the %%Body-BgColor extension. Enter code like this at the beginning of the program:

Print-Direct Printer=html '%%Body-BgColor #0000FF'

To set the background color for the navigation bar, enter code like this:

Print-Direct Printer=html '%%Nav-Body-BgColor #0000FF'

See “Specifying HTML Colors.”

Specifying Background Images

To use a background image for the report pages that the enhanced HTML generates, insert the %%Background extension at the beginning of the program:

Print-Direct Printer=html '%%Background tile.gif'

To set the background image for the navigation bar, enter code like this:

Print-Direct Printer=html '%%Nav-Background D:\jpegdir\house.jpg'

The background attribute can be any valid URL. If you do not specify the %%Nav-Background extension while specifying the body background, the background image that you specify for the body is used both in the body and in the navigation bar. If you do not want an image to appear in the navigation bar, use code like this:

Print-Direct printer=html '%%Nav-Background EMPTY'

Specifying Links

The %%Href extension specifies a link in the report. This extension enables you to make a text, number, image, or chart object into a link. The object can be the item that you click to activate the link or it can be the location on the page where the link takes you. Specify the latter by using the %%Anchor extension. For example:

Print-Direct Printer=html '%%Href #section2'
Print 'ABC' ()
...
Print-Direct Printer=html '%%Anchor section2'
Print 'XYZ' ()

In this example, clicking the ABC text on the page jumps to the XYZ text. When using frames or multiple browser windows, you can control which frame displays the target of the link by using the target option of the %%Href extension. For example, specify on one line:

Print-Direct Printer=html '%%Href target="_top" http://www.peoplesoft.com'

Specifying Text Colors

Use the %%Color and %%ResetColor extensions to change the color of text. The following code example demonstrates this capability:

If &Salary > 100000
Print-Direct Printer=html '%%Color #FF0000'
End-If
Print &Salary ()
If &Salary > 100000
Print-Direct Printer=html '%%ResetColor'
End-If

In this example, when the value of the column is more than 100,000, it prints in red. The %%Color extension affects all text (and number) printing from this point on. This behavior is similar to that of the ALTER-PRINTER command. A subsequent invocation of %%Color with a different color value sets the current color to a new color. To restore the color to the default (normally, black) use the %%ResetColor extension.

Specifying HTML Colors

Specifying color as a red-green-blue (RGB) hexadecimal value is the only way to designate color in SQR. Your browser documentation should contain a listing of supported colors and their hexadecimal values. To specify color as an RGB hexadecimal value, enter a # character followed by six hexadecimal digits. The first two digits specify the intensity of the red, the next two specify the green, and the last two specify the blue. For example, green is #00FF00.

Including Your Own HTML Tags

Enhanced HTML extensions enable you to include your own HTML tags in the output. These tags are passed through to the output without change. Use this feature to include advanced HTML capabilities such as JavaScript and <APPLET> tags.

SQR PRINT with CODE-PRINTER=HT enables you to inject any text into the HTML output. SQR does not check the text that you are printing. This text can contain anything that your browser understands. Do not use this method for formatting, because your formatting may conflict with -PRINTER:EH-enhanced HTML formatting. -PRINTER:EH-enhanced HTML uses HTML tables extensively. To fully control the formatting, use the HTML procedures that are defined in html.inc and that are documented in this section. By invoking the html_on procedure, you instruct the enhanced HTML to perform no formatting. Specify all formatting by using the HTML procedures in html.inc or by using SQR PRINT with CODE-PRINTER=HT to insert HTML code. When you use SQR PRINT with CODE-PRINTER=HT, the enhanced HTML does not translate special symbols that are used in HTML tags, such as <, >, and &.

Another method for generating HTML output from an SQR program is running a program with the command-line flag -PRINTER:HT. Alternatively, you can make some simple modifications to the program. Add either DECLARE-PRINTER with the TYPE=HT argument or USE-PRINTER-TYPE HT.

With these methods, HTML output is generated in the following way:

  • All output appears as preformatted text by using the <PRE> and </PRE> HTML tags.

  • Text appears on the page at the position coordinates that are specified in the SQR program.

  • Text appears in a fixed-width font, such as Courier.

  • Font sizes map to HTML font sizes.

  • HTML reserved characters map to the corresponding HTML sequence.

    The <, >, &, and " characters map to the &lt;, &gt;, &amp;, and &quot;, character sequences, respectively, thus preventing the web browser from mistaking such output as an HTML sequence.

The sample program ex7a.sqr produces a simple master and detail report. By running it with -PRINTER:HT, you can produce HTML output. A left frame is produced with links to each page of the report. The right frame features a navigation bar that appears at the top of every page in the report. The navigation bar enables you to move to the first or last page or to move one page forward or backward from your relative page viewing position.

SeeUsing the DECLARE-PRINTER Command and Understanding Printer-Independent Reports.

With SQR, you can generate HTML format reports by using -PRINTER:EH or -PRINTER:HT command-line flags. If you want HTML files to be smaller in size for faster load times or to be divided on the basis of report page ranges, or if you want to preview the table of contents for a report in your web browser without generating an entire report, use -BURST:{xx} with -PRINTER:EH or -PRINTER:HT.

By using -BURST:P (or BURST:P1) with -PRINTER:EH or by using -BURST:P1 with -PRINTER:HT, you can generate HTML output files that are burst by report page numbers, one report page per .htm file. (This practice is frequently referred to as demand paging.) As a result, a 25-page report would be divided into 25 separate .htm output files. By using -PRINTER:HT, you can also specify the report page ranges that you want within an HTML file. For example, -BURST:P0,1,3-5 generates an HTML file containing only report page numbers 1, 3, 4, and 5. You can then focus on information that is truly of interest.

Similarly, if you specify -PRINTER:HT with -BURST:T, only the table of contents file is generated. And if you specify -PRINTER:HT with -BURST:S, report output is generated according to symbolic table of contents entries. By using -BURST:S, you can specify the numeric level to burst on (for example, -BURST:S2 bursts on level 2). If you have used DECLARE-TOC and TOC-ENTRY commands in the SQR program, the table of contents provides more detailed information than just page number links, as illustrated by the following code example.

To use DECLARE-TOC and TOC-ENTRY to improve the information that is available in generated HTML output, this example adds the following code example to the beginning of the sample program ex7a.sqr:

begin-setup
declare-toc common
       for-reports=(all)
       dot-leader=yes
       indentation=2
end-declare
end-setup

The code example also adds this code to the body of the program, in the main procedure immediately following the begin-select and Print ‘Customer Information’ (,1):

toc-entry text = &name

Use the SQR HTML procedures html_set_head_tags and html_set_body_attributes to define a title and background image for a report. To use these procedures, the SQR program must include the html.inc file. You must also run the program by using the -PRINTER:HT command-line flag.

These procedures must be called at the start of the program. For example:

do html_set_head_tags('<TITLE>Monthly Report</TITLE>')
do html_set_body_attributes('BACKGROUND="/images/mylogo.gif"')

The first line of this code example displays the Monthly Report title. Specifically, the entire '<TITLE>Monthly Report</TITLE>' sequence is passed as an argument to the html_set_head_tags procedure. The argument is enclosed in single quotes.

The second line displays the mylogo.gif background image for the web page. Again, an argument is passed to the procedure. The entire argument is enclosed in single quotes, and the file name and path are enclosed in double quotes.

Together, these two lines of code generate the following HTML output:

<HTML><HEAD><TITLE>Monthly Report</TITLE></HEAD>
<BODY BACKGROUND="/images/mylogo.gif">

Using additional HTML procedures in the SQR program provides enhanced capabilities, including:

  • Highlighting , including HTML physical tags and logical markup tags.

    HTML physical tags include subscript, superscript, and strikethrough. HTML logical markup tags include citation, code, keyboard, and sample.

  • Headings.

  • Links.

  • Lists , including ordered lists, unordered lists, definition lists, directory lists, and menus.

  • Paragraph formatting , including paragraph breaks, line breaks, and horizontal dividers.

  • Tables , including captions, rows, columns, and column headings.

An SQR report named myreport.sqr creates a FRAME file (myreport.htm) and report output files. The OUTPUT-FILE-MODE entry in the Default-Setting section of the PSSQR.INI file controls the report output file extensions. When this entry is set to SHORT, the report output files use the form myreport.hzz, and when set to LONG, the files use the form myreport_zz.htm. The value of zz ranges from 00 to 99 and reflects the report number.

The FRAME file displays a list (links) of report pages in one frame and the report text in another frame. Each report output file contains a list of pages (links) at the end of the file. If myreport.sqr created multiple reports, then the FRAME file contains a link to each report output file. In addition, each report output file contains links to the other report output files that were created during the program run.

When an SQR program produces HTML output, you can preview it on a local system. This is a good way to test the output before you publish it on a website.

To test the output of the program, open the file in the web browser. If your web browser supports the HTML FRAME construct, open the FRAME file (myreport_frm.htm); otherwise, open the report output file (myreport.h00, myreport_00.htm).