The PRINT actions
Home Up The STACK actions The SMTP actions The MAPI actions The FILE actions The PRINT actions Credit Card Validation The GENERATE Actions

 

The PRINT action causes the results of the current form to be stacked. The current content of the stack is then used as items to replace "variables" in a "template" HTML form, which is then printed. The PRINTC action performs the same function, but then clears the content of the stack once printing has taken place.



Specify this action as the ACTION parameter of the FORM tag. The HTML page to jump to after printing is complete may also be specified after a + sign. For example, to specify that you want to substitute variables in, and then print the prt.htm page when the user submits the form, then jump to the thanks.htm page, specify

FORM Method="POST" Action=PRINT?prt.htm+thanks.htm

You can also add a target frame name to the redirection page if you are using Frames by enclosing the frame name in brackets at the end, so if for example you wanted the redirection page to appear in a frame called "main" you would need to specify 

FORM Method="POST" Action=PRINT?john.doe@somewhere.com+thanks.htm(main)


In the prt.htm page you should include comments that include the field name surrounded by the @ character. For example, assuming the form's field name was "Address" then the comment would need to be

<!--@Address@-->

In the case of form elements that can return multiple lines of data (multiple select fields and input boxes etc.) the replacement is multiple lines separated by carriage return/line feed pairs. To maintain these carriage returns you might want to be within the scope of a "preformatted" tag. Also consider using tables to help you lay out your printed document, you can get some very neat looking printed documents using tables.

It is also possible to generate and print "repeating lines". Imagine a Shopping Cart application, where the user can travel around the presentation, selecting multiple items, which you want to print in a list.  To achieve this you need to give all the items the same variable name. You then need to include in your template page two comments that surround the HTML that needs to be repeated the number of times the variable appears in the stack. Define the start of the repeating HTML using a <!--@WCREPEAT@--> comment, and define the end of the repeating HTML with a <!--@WCREPEND@--> comment. WebCompiler will determine the variable(s) that appear in the repeating HTML, and will repeat the HTML, replacing the variable each time with the next value of that variable on the stack, until all the items for that variable have been used. There can be multiple variables with the repeating HTML, and WebCompiler will keep repeating while at least one of those variables has further values. There can also be multiple repeating sections, each enclosed within <!--@WCREPEAT@--> and <!--@WCREPEND@--> comments. You cannot nest these repeating comment markers however. A useful technique is to encase a table row definition inside the repeating markers - the table then grows to the number of rows required to accommodate all the variable values.

This is quite complex to grasp. If you need an example, take a look at our "Shopping Cart" example at our Web site at http://www.webcompiler.com and download the source HTML we used to create it.

No links are needed to the "template" HTML page. In fact you probably don't really want any way for the user to access the template form directly.

For an example of using the Print action, review the printable order forms for WebCompiler itself. They are in the \demoweb subdirectory relative to where you installed WebCompiler. The UK Order form has the filename ukform.htm and the accompanying print template has the name ukprint.htm.

Note for FrontPage 98 users. Getting the HTML comment in correctly without FrontPage adding things you don't want can be quite tricky. You need to use the Insert menu, then select the FrontPage Component option. Then select the Insert HTML option (not the Comment option, it puts extra fluff around it that will prevent it from working). In the resultant box you need to type the comment as shown above, including the leading and trailing < and >. The other alternative is to edit the HTML directly and put it in that way.