JavaScript Internal API - exeoutput object

ExeOutput for PHP features its own script language HEScript which allows you to control your applications. Since you can also use JavaScript in your HTML pages, the Dynamic HTML Object Model was extended so you can also 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 works using asynchronous callbacks. This means that the functions below do not return any useful result: the real result is returned thanks to a callback (see below).

List of exeoutput methods

Method namePrototypeDescription, comments
CloseCurrentWindowprocedure exeoutput.CloseCurrentWindow();Closes the current window (it can prompt end users).
GetGlobalVariablefunction 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.
SetGlobalVariableprocedure 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.
RunHEScriptComfunction 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.
RunHEScriptCodefunction exeoutput.RunHEScriptCode(Code)This function lets you compile and execute HEScript code specified by Code directly.
GetHEScriptComfunction 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).
GoToPageprocedure 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.
GetStringfunction exeoutput.GetString(ID,Callback);Returns the resource string whose name is given by ID.

Examples

To call an HEScript function, you can also use this JavaScript function:

function executecom(sname)

{

return exeoutput.RunHEScriptCom(sname);

}

For instance, if you want 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] by 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:

Introduction to scripting

How to call HEScript procedures/functions?


Copyright G.D.G. Software 2018. All Rights Reserved.