[This is preliminary documentation and subject to change]

## ProcessForm

The ProcessForm method merges data from a template file with form data submitted by a user, and creates a new file. The data submitted by the user can be manipulated by script in the template file.

###### Syntax

oTools.ProcessForm(OutputFileURL, TemplateURL, [InsertionPoint])

###### Parameters

OutputFileURL
  A string containing the relative URL of the file to which the merged data is written.
TemplateURL
  A string containing the relative URL of the template file.
InsertionPoint
  An optional parameter indicating where in the template file to start inserting the process data. This parameter has not been implemented. If you include a value for this parameter it will be ignored.

Note The template file can contain ASP scripts.

A script between <% and %> delimiters is treated just like other text in the template and copied into the output file. If the output file is an ASP document, the script will run when the output file is executed.

If you want script in the template to be executed during the call to ProcessForm, place your code between special <%% and %%> delimiters. Since these scripts are executed before the template data is saved in the output file, the results get saved in the output file, usually as standard text.

If the specified output file exists, the server will overwrite it.

If the InsertionPoint parameter does not exist, Tools.ProcessForm replaces the entire output file. If the InsertionPoint parameter exists, and does not begin with an asterisk (*), Tools.ProcessForm finds the InsertionPoint string in the output file and inserts the data immediately after it. If the InsertionPoint string begins with an asterisk (*), Tools.ProcessForm finds the InsertionPoint string in the output file and inserts the data immediately before it. If the InsertionPoint string exists, but is not found in the output file, the data is appended to the end of the file.

###### Example

The following example uses two files. Tools_Template.asp is a template file for a personal Web page. Tools_ProcessForm.asp takes some input from a user, and calls ProcessForm to copy the template data to a new file with the updates given by the user. Run the example by browsing to Tools_ProcessForm.asp.

--- Tools_Template.asp ---

    <HTML>
    <HEAD>
    <TITLE><%% =Request.Form("company") %%></TITLE>
    </HEAD>

    <BODY bgcolor="<%% =Request.Form("bgcolor") %%>">
    <FONT face="<%% =Request.Form("fface") %%>" size=<%% =Request.Form("fsize") %%>>

    <H5 align=center>This file was created on <%% =Date %%> at <%% =Time %%></H5>

    <%
      Response.Write "<H3 align=center>Welcome to the home page for:</H3>"
      Response.Write "<H1 align=center><%% =Request.Form("company") %%></H1>"
      Set MyPageCounter = Server.CreateObject("MSWC.PageCounter")
      MyPageCounter.PageHit
      Response.Write "<P align=center>This page has been hit " & MyPageCounter.Hits & " times."
    %>

    <P><B>About my Company:</B>
    <P><%% =Request.Form("about") %%>

    </FONT>
    </BODY>

    </HTML>

--- Tools_ProcessForm.asp ---

    <HTML>
    <HEAD><TITLE></TITLE></HEAD>
    <BODY>

    <%
      OutputURL = Request.Form("outputurl")
      BGColor   = Request.Form("bgcolor")
      FFace     = Request.Form("fface")
      FSize     = Request.Form("fsize")
      Company   = Request.Form("company")
      About     = Request.Form("about")

      Process = True
      If "" = OutputURL Then Process = False
      If "" = BGColor Then Process = False
      If "" = FFace Then Process = False
      If "" = FSize Then Process = False
      If "" = Company Then Process = False
      If "" = About Then Process = False
    %>

    <H3>Create a Default Company Page Using the Tools_Template.asp Template</H3>

    Please fill out the form.  All fields are required.
    <FORM NAME="GetTemplateStuff" METHOD="POST" ACTION="Tools_ProcessForm.asp">
    <input type="TEXT" NAME="outputurl" size=70 value="<%=OutputURL%>"> Relative Output URL<BR>
    <input type="TEXT" NAME="bgcolor" size=70 value="<%=BGColor%>"> Background Color<BR>
    <input type="TEXT" NAME="fface" size=70 value="<%=FFace%>"> Font Face<BR>
    <input type="TEXT" NAME="fsize" size=70 value="<%=FSize%>"> Font Size<BR><BR>
    <input type="TEXT" NAME="company" size=70 value="<%=Company%>"> Company Name<BR>
    <input type="TEXT" NAME="about" size=70 value="<%=About%>"> About Your Company<BR><BR>
    <INPUT type="SUBMIT" VALUE="Create File">
    </FORM>

    <%
      If Process Then
        Set oTools = Server.CreateObject("MSWC.Tools")
        oTools.ProcessForm OutputURL,"Tools_Template.asp","<HTML*>"
    %>
        <P><A href="<%=OutputURL%>"><%=OutputURL%></A> was created.
    <%
      Else
        Response.Write "No file was created because of missing inputs."
      End If
    %>

    </BODY>
    </HTML>

###### See Also

FileExists, Random

© 1997-2001 Microsoft Corporation. All rights reserved.