Skip to content

JavaScript Internal API - exeoutput object

ExeOutput for PHP features its own scripting language, HEScript, which allows you to control your applications. Since you can also use JavaScript in your HTML pages, the Dynamic HTML Object Model has been extended so you can control your application through JavaScript: some JavaScript "external" commands (a.k.a. methods) are accessible from the exeoutput object.

For instance, the following JavaScript code will close the application:

exeoutput.RunHEScriptCode('ExitPublication;');

Warning

The JavaScript extension operates using asynchronous callbacks. This means that the functions below do not return any immediate results: the actual result is returned via a callback (see examples below).

List of exeoutput methods

Method name Prototype Description, comments
CloseCurrentWindow procedure exeoutput.CloseCurrentWindow(); Closes the current window (it can prompt end users).
GetGlobalVariable function exeoutput.GetGlobalVariable(Name, DefaultValueIfNotFound, Callback) Returns the value of the global variable whose name is Name. If the global variable does not exist, the DefaultValueIfNotFound is returned. Result is returned thanks to the Callback JS function (see below). Similar to GetGlobalVar HEScript function.
SetGlobalVariable procedure exeoutput.SetGlobalVariable(Name, Value; IsStored: WordBool) Sets the Value of a global variable whose name is Name. If IsStored is true, the global variable is persistent: its value will be stored and restored the next time the application is run. Similar to SetGlobalVar HEScript function.
RunHEScriptCom function exeoutput.RunHEScriptCom(ComLine) This function lets you execute an HEScript function or procedure and returns its result (in case of a function). It is similar to the hescript:// protocol, except that you specify the command line via ComLine and a default value in DefValue if the function is not found.
RunHEScriptCode function exeoutput.RunHEScriptCode(Code) This function lets you compile and execute HEScript code specified by Code directly.
GetHEScriptCom function exeoutput.GetHEScriptCom(ComLine, Callback) This function lets you execute an HEScript function and get its result. It is similar to the hescript:// protocol, except that you specify the command line via ComLine. Syntax for ComLine below. Result is returned thanks to the Callback JS function (see below).
GoToPage procedure exeoutput.GoToPage(URL, Window); This function causes the application to navigate to the URL specified by URL and in the window named by Window. Window should be left to blank.
GetString function exeoutput.GetString(ID,Callback); Returns the resource string identified by ID.

Examples

To Call an HEScript Function Using JavaScript:

function executecom(sname)
{
return exeoutput.RunHEScriptCom(sname);
}

For instance, to call the HEScript procedure UserMain.Procedure1, use: javascript:executecom("UserMain.Procedure1") or javascript:exeoutput.RunHEScriptCom("UserMain.Procedure1")

To display a resource string in an HTML page, use this code:

<script language="JavaScript">

function DemoCallback(content) {
  document.getElementById('demo').outerHTML = '<p>' + content + '</p>'; 
 }    
</script>

<div id="demo"></div>  

<script language="JavaScript">
exeoutput.GetString("[Name]", DemoCallback);
</script>
where you replace [Name] with the name of the resource string you want to display.

Get the value of a global variable

<script language="JavaScript">
function DemoCallback(content) {
alert(content);
}    
</script>
<script language="JavaScript">
exeoutput.GetGlobalVariable( '[Name]', DemoCallback );
</script>
where you replace [Name] by the name of the global variable. See the list of pre-defined global variables.

Call an HEScript String Function and Return Its Result With exeoutput.GetHEScriptCom(ComLine, Callback)

JavaScript code:

<script language="javascript">

 function DemoCallback(content) {
  alert(content); 
 }

 exeoutput.GetHEScriptCom('usermain.getit|password1', DemoCallback);

</script>

This code calls this HEScript string function defined in UserMain:

function getit(what: String): String;
begin
Result := MD5OfAString(what);
end;

Close the application with JavaScript and RunHEScriptCode

exeoutput.RunHEScriptCode('ExitPublication;');

See these topics also:

JavaScript window extension

Introduction to scripting

How to call HEScript procedures/functions?