SBM ModScript Reference → Introduction to SBM ModScript → SBM ModScript Contexts → Direct Access Contexts → HTML Template Direct Access Context
Every SBM browser page is generated from an HTML template containing HTML and proprietary server-side instructions. If an HTML template contains the server-side instruction $SCRIPT(), with proper parameters, the server runs the specified script. In the outgoing HTML, the entire $SCRIPT instruction is replaced by the script's output. If the script's output is valid HTML, it is visible in the browser. For an example of $SCRIPT() usage, see below.
To view an HTML template, browse to an SBM URL containing the parameter "Template=name", where "name" is the file name of the template, excluding the "htm" extension. For example, the URL for the About page is as follows:
http://server/workcenter/tmtrack.dll?StdPage&Template=about
If the HTML template contains a $SCRIPT tag, the output of that script is visible on the page.
Any optional parameters following the name/ID are inserted into a Dictionary object which is passed to the script. The Dictionary of optional parameters is accessible from within the script as "Shell.Params()." Shell.Params() supports the methods and properties of a Dictionary.
The value of the Nth optional parameter is associated with a key called "paramN." For example, the first optional parameter is "param1."
Create a script called myScript:
var sText1; var sText2; Shell.Params().Item( "param1" ); Shell.Params().Item( "param2" ); Ext.WriteStream( "<HTML>"); Ext.WriteStream( "<HEAD><TITLE>Script Test</TITLE></HEAD>" ); Ext.WriteStream( "<BODY>" ); Ext.WriteStream( "Param1: " ); Ext.WriteStream( "<H2>" &&& EncodeHTML(sText1) &&& "</H2>" ); Ext.WriteStream( "<BR>" ); Ext.WriteStream( "Param2: " ); Ext.WriteStream( "<H2>" &&& EncodeHTML(sText2) &&& "</H2>" ); Ext.WriteStream( "<BR>" ); Ext.WriteStream( "</BODY>" ); Ext.WriteStream( "</HTML>" );
Create an HTML file called scripttest.htm, and add the following text to it:
$SCRIPT( myScript, Godzilla, King Kong );
Save this file in the SBM installation templates directory.
Use the following URL to test the $SCRIPT mechanism:
http://server/workcenter/tmtrack.dll?StdPage&Template=scripttest
Copyright © 2007–2019 Micro Focus or one of its affiliates. All rights reserved.