Example
An example shows how this fits together. In this scenario, we want to define a function that retrieves additional parts of a tree control. The function will use the GetChildren() method of a class named %CSP.Documatic.Helper. The method takes three string arguments: name, parent, and ns and it returns a fully formed piece of HTML that is meant to be added to the page within the tree control. (For our purposes here, it does not matter exactly how that tree control works or exactly what this method does.)
Within the code that generates the <head> for this HTML page, we call both HyperEventHead() and HyperEventCall() as follows:
//Add hyperevent-related scripts for left navigation
set headhtml=_..HyperEventHead()
_"<script>function addChildrenAfter(item,name,Id,ns) {"
_"var h="_..HyperEventCall("%CSP.Documatic.Helper.GetChildren","name,Id,ns",1)_";"
_"if (h!==null) {"
_"item.insertAdjacentHTML('afterend',h); } else {"
_"location.reload();}"
_"return false;"
_"}</script>"
The resulting HTML looks like this (with line breaks added and edits for readability):
<script type="text/javascript" src="/somelocation/csp/broker/cspxmlhttp.js">
</script>
<script type="text/javascript" src="/somelocation/csp/broker/cspbroker.js">
</script>
<script>function addChildrenAfter(item,name,Id,ns)
{var h=cspHttpServerMethod("pyK473ekNn0...very long...DOKepQ",name,Id,ns);
if (h!==null) {item.insertAdjacentHTML('afterend',h);
} else {location.reload();
}return false;}</script>
Notice that this HTML does not include the name of the server method, but instead includes a long token that the server uses to identify the code to run. Also note that this HTML includes cspHttpServerMethod, which is a JavaScript function provided by HyperEventHead().