SCRIPT
Scripts offer authors a means to extend HTML documents in highly active and interactive ways. For example:
- Scripts can be evaluated as a document loads to modify the contents of the document dynamically.
- Scripts can accompany a form to process input as it is entered. Designers can dynamically fill out parts of a form based on the values of other fields. They can also ensure that input data conforms to predetermined ranges of values, that fields are mutually consistent, etc.
- Scripts can be triggered by events that affect the document, such as loading, unloading, element focus, mouse movement, etc.
- Scripts can be linked to form controls (for example, buttons) to produce graphical user interface elements.
In the agent web interface, the SCRIPT tag is mainly used to call Chilli scripts which do most of the internal work within the agent interface. However, the SCRIPT tag can also call other scripts, such as Unix shell scripts or others.
Scripts can be either included into the HTML file if they are only applicable in a specific situation, or they can be stored in separate files. Since most scripts are applicable in more that one situation, those are stored in separate HTML files under the ScriptLib directory. These scripts are called via the BMC Software INCLUDE tag. Depending on the context of the script, its execution can then result in other scripts being executed, in a direct HTML output or an output which is then parsed again before being passed on to the browser.
When encountering a SCRIPT tag in an HTML file, the parser checks the ScriptInterpreters section of the webconsole.ini file for an entry matching the supplied language name. If it does not find a non-blank value, it passes the tag and its contents to the browser without changes. If it finds an entry in the .ini file with a non-blank value, it assumes that the value is the path of the interpreter to be used for handling the script. In this case it copies the text between the <SCRIPT>and </SCRIPT> tags into a temporary file and executes it using the supplied path. The path can be relative (for example, sh.exe /bin/sh
The default value of the language parameter is "Chilli". If the language specified is "Chilli" or the lang parameter is absent, the script tag will treat the value as a Chilli script. If the parameter value is not Chilli or empty, the parser will check the .ini file for the value specified in the lang parameter.
Start Tag | required |
End Tag | required |
Syntax | <SCRIPT [language='script language'] [vars='variable name(s)'] [parseoutput]></SCRIPT> |
Mandatory Parameters
There are no mandatory parameters for this tag.
Optional Additional Parameters
The language parameter defines the program with which the script is to be executed. | |
The variable parameter vars defines which variables are being used in the script. | |
If the parseoutput parameter is supplied with the SCRIPT tag, the output after the script was run is parsed again by the parser. |
language
The language parameter defines the program with which the script is to be executed. The default value is chilli. If the language parameter is missing, the parser automatically interprets the language parameter as being Chilli.
Example 1
The following script is written in JavaScript and after execution shows the language choices for the the agent interface.
<IMG src="/common/images/bulletsubsection.png" width="13" height="11">
<SPAN class="LOCATION">
<SCRIPT language='Javascript'>document.write (FindTranslation ("_MENU_KIOSK_"));</SCRIPT>
</SPAN>
<IMG src="../../../common/images/bulletsubsection.png" width="13" height="11">
<SPAN class="LOCATION">
<SCRIPT language='Javascript'>document.write (FindTranslation ("_MENU_LIST_"));</SCRIPT>
</SPAN>
<!-- End location -->
Example 2
An HTML file contains the following SCRIPT tag:
When the parser encounters this tag it will check the ScriptInterpreters section of the webconsole.ini file for an entry called bourneshell. This section contains the following entry:
BourneShell=/bin/sh
This entry tells the parser that the executable with which to execute the script is a Unix shell script called "sh", which is located in the local bin directory. Note, that the language name and the entry in the .ini file are not case sensitive, so 'bourneshell' and 'BourneShell' are equivalent.
The parser now places the text between the <SCRIPT> and </SCRIPT> tags into a newly created temporary file and executes this file with the unix shell "sh".
vars
The variable parameter vars defines which variables are used in the script. The variables need to be defined before the SCRIPT tag through the SETVAR parameter. If the script language is Chilli, no vars parameter is needed, because the Chilli scripts are run inside the HTML pages, where all variables are already mentioned. All other scripts run outside the HTML pages and need the variables specified in order to run.
parseoutput
If the parseoutput parameter is supplied with the SCRIPT tag, the output after the script was run is parsed again by the parser. If the parseoutput parameter is not mentioned, the output will be directly displayed on screen.
Example
The following code is from the HCHL file creating the layout of MyApps page in the browser:
Source File
Print ("<INCLUDE htmlfile='"+ HTTP_DOCUMENT_ROOT + "common/scripts/tabs.hchl'>" + ENDLINE)
</SCRIPT>