The ExpandScript method method is used to expand script pages that contain FoxPro expressions and Code blocks using Active Server like syntax. The method generates a fully self contained HTML page/HTTP output which includes an HTTP header.

This class uses the wwScripting class to parse expression blocks and codeblocks. ExpandScript() behavior can be called explicitly or is available through generic script processing in the wwScriptMaps process handler which can be mapped for any extension in your server's Process method.

ExpandScript() call syntax Examples:

Response.ExpandScript()                     && Request.PhysicalPath() is used
Response.ExpandScript("~\scriptdemo.wcs")   && Virtual Path as base
Response.ExpandScript(Config.cHtmlPagePath + "scriptDemo.wcs")

Example HTML markup:

<div class="customer-list">
       SELECT * from Customers INTO CURSOR TQuery
        <div class="customer-item">
            <div class="company-text"><%= TQuery.Company %></div>
            <div class="company-date"><%= TQuery.Entered %></div>
    <% ENDSCAN %>
o.ExpandScript(tcPageName, tnMode, tvContentType, tlReturnAsString)

Return Value



Optional - Name of the page from disk to expand. Optionally, this can be the actual string of the script to evaluate. If not provided Request.GetPhysicalPath() is used.

Also supports ~ for referencing the Application Virtual root path:

Optional - Determines the compilation mode for scripts. Default Mode is 1. For more info see wwServer::nScriptMode.

  • Dynamic Compilation
  • Precompiled FXP files
  • Interpreted with ExecScript

Optional - Either a wwHTTPHeader object or a content type string. "none" write no header.

Optional - return the output from rendering as a string and don't write out to the Response stream. No HTTP header is generated in this mode.


The Server.lDebugMode flag determines the level of error information that is displayed. With DebugMode .T. the source error is displayed in the page and a PRG file is generated that you can examine in the same directory as the script file. With DebugMode .F. the PRG file is not generated and wwScripting will not be able to retrieve or display the location of the error only the error message.


Expression Examples:

<%= DateTime() %>
<%= lcVar %>
<%= TQuery.FieldName %>
<%= MyFunction() %>

Code Block Examples:

<div class="container">
    	lcOutput = ""
	    for x = 1 to 5
    	    lcOutput = lcOutput + TRANS(x) + "<br>"
		<%= lcOutput %>

	    SELECT Company from TT_CUST INTO CURSOR TQuery 
	<div class="company-item">
		<div class="company-text"><%= Company %></div>	

	<% ENDSCAN %>

To exit a script issue RETURN as part of a script block:

   IF llCanceled 
      RETURN && Exit script

Script pages have access to a special wwScriptingHttpResponse object which provides the ability to write output into the HTTP stream using Response. methods. From within script code you can add headers, cookies and otherwise manipulate the Response.

   lcOutput = "New Value"

   Response.AddCookie("SomeCookie","Some Value")
   Response.AddCookie("MyCookie","My Cookie Value","/",Date() + 10)


See also:

Class wwResponse | wwResponse::ContentTypeHeader | wwResponse::ExpandTemplate

© West Wind Technologies, 1996-2024 • Updated: 11/01/2018
Comment or report problem with topic