DEFTAG
The DEFTAG tag provides a means for agent interface developers to define their own tags that call user-defined Chilli procedures. (The majority of commands in the agent interface are executed through Chilli scripts.)
Start Tag | required |
End Tag | forbidden |
Syntax | <DEFTAG name='tag name' 'proc='procedure name' [parseoutput]> |
Mandatory Parameters
The name of the tag to be defined. | |
The name of the Chilli procedure which will handle the tag when it is encountered in an HCHL file (=calling a Chilli procedure). |
Optional Additional Parameters
Defines if the output of the execution of the chilli script is to be parsed again. If the parseoutput parameter is not mentioned in the tag, the Chilli generated output will not be re-parsed before being passed to the browser. |
name
The BMC Software DEFTAG expects the name parameter to define the name of the new tag. The naming conventions for new tag names are the same as the naming rules in the Chilli language, that is:
- The name may have a maximum length of 32 characters.
- The name may be any combination of alphanumeric characters ( that is, letters, digits, and underscores.
- The name may be in lowercase or uppercase or a mixture of both.
- The name may start with an underscore (_) or a letter, but not with a digit.
- The name must not contain any spaces.
- The name must not be a reserved statement, a function name, or a keyword.
- The name must not be an already declared variable or constant.
Example
The following example shows an excerpt that creates a tag called SUBMIT that draws the submit buttons (Apply, Reset, Cancel, etc.) on the screen.
proc DrawSubmitTag (HtmlTagList HtmlFile, int index)
string szFormName, szTarget, szButtons
int iButtons
GetTagParamValueStr (HtmlFile, index, "formname", "", szFormName)
GetTagParamValueStr (HtmlFile, index, "target", "", szTarget)
GetTagParamValueInt (HtmlFile, index, "buttons", SUBMIT_ALL, iButtons)
DrawSubmit (szFormName, szTarget, iButtons)
endproc
</SCRIPT>
<DEFTAG name=SUBMIT proc=DrawSubmitTag>
proc
The BMC Software DEFTAG expects the proc parameter to declare the name of the procedure which defines the new HCHL tag. The naming rules for the procedure are the same as those for the new tag name. The defined procedure has a fixed signature and must include the following arguments:
Syntax
HchlFile | contains the list of all tags called by the procedure. For more information about this structure, see the Chilli Reference Manual in Section II under the heading HTML Functions. |
Index | the number of tags called by the procedure. |
Example
The following script excerpt of an HCHL file defines two new tags PRINT and MAILTO in its procedures and declares them then through the DEFTAG.
....
proc HandlePrint (HtmlTagList HtmlFile, int index)
print (StrEvalAsString (HtmlFile.Tags[index].TagParams[1].TagParamValue))
endproc
proc HandleMailto (HtmlTagList HtmlFile, int index)
string mailto
mailto = StrEvalAsString (HtmlFile.Tags[index].TagParams[1].TagParamValue)
print ("<A href='mailto:" + mailto + "'>" + mailto + "</A")
endproc
....
</SCRIPT>
<DEFTAG name=PRINT proc=HandlePrint>
<DEFTAG name=MAILTO proc=HandleMailto>
parseoutput
If the parseoutput parameter is supplied with the DEFTAG tag, when the script is run, the output is parsed again. If the parseoutput parameter is not mentioned, then the output, in whichever format it was returned by the script, will display on the screen.
Example
The following script is an excerpt of an HCHL file that defines a procedure to display panels on the screen.
proc DrawPanelTag (HtmlTagList HtmlFile, int index)
string title, width, height, name
int buttons, NoTitle
bool fNoTitle
GetTagParamValueStr (HtmlFile, index, "title", "", title)
GetTagParamValueInt (HtmlFile, index, "buttons", 0, buttons)
GetTagParamValueStr (HtmlFile, index, "name", "", name)
GetTagParamValueStr (HtmlFile, index, "height", "400", height)
GetTagParamValueStr (HtmlFile, index, "width", "250", width)
GetTagParamValueInt (HtmlFile, index, "notitle", 0, NoTitle)
....
if (NoTitle == 1)
fNoTitle = TRUE
else
fNoTitle = FALSE
endif
DrawPanel (title, buttons, name, height, width, ...., fNoTitle)
endproc
</SCRIPT>
<DEFTAG name=PANEL proc=DrawPanelTag parseoutput>