The GENERATE 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 GENERATE 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 page, which is then displayed. The GENERATEC action performs the same function, but then clears the content of the stack once variable substitution has taken place.

Specify this action as the ACTION parameter of the FORM tag. The template page to be used is specified after a ? character. For example, to specify that you want to substitute variables in, and then display the list.htm page when the user submits the form, specify

FORM Method="POST" Action=GENERATE?list.htm

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

<!--@Address@-->

which will be replaced as the form appears.

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.

It is also possible to generate "repeating lines". Imagine a Shopping Cart application, where the user can travel around the presentation, selecting multiple items. Just before he confirms his order you might want him to review all the items he has ordered. 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 page directly.

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.