HEScript can be used in multiple ways:
- PHP and HTML pages
- HTML links
- JavaScript functions
- Global application events
This topic explains how to call HEScript functions and procedures.
Using HTML Links #
You can call HEScript procedures and functions from HTML links. Use the hescript:// protocol prefix (instead of http://) to tell the application to execute an HEScript procedure or function.
The syntax is hescript:[ScriptName].[ProcedureOrFunctionName].
Examples: hescript://MyScript.Procedure1 or hescript://UserMain.OnNavigateComplete
In HTML code:
<a href="hescript:MyScript.Procedure1">Click here to execute my first function</a>
For instance, suppose we wrote a small script named demo1 in the Script Manager that contains the following procedure:
procedure MyFirstDemo;
begin
MessageBox("This is a simple message.", "First Demo", MB_OK + MB_ICONINFORMATION);
end;
The following HTML code would then call it:
<a href="hescript:demo1.MyFirstDemo">Click here to execute this function</a>
If your procedure or function uses string parameters, you can pass them using a | (%7C) separator. Note: only string parameters are supported with this method.
Warning
Recent versions of Chromium require the | character to be encoded in HTML links: %7C
Syntax:
hescript://[scriptname].[functionprocedurename]%7Cparam1%7Cparam2%7C...%7CparamN
Example:
hescript://MyScript.ProcedureA%7Ctest
Warning
Important: Please properly URL-encode any non-ASCII characters in parameters. ExeOutput for PHP will decode them automatically.
URL encoding replaces unsafe ASCII characters with a % followed by two hexadecimal digits. For example, spaces in filenames should be replaced by %20.
To convert characters online, you can use a tool like the one at w3schools.com.
Demonstration with Parameters #
Here is a second example. The script procedure in “demo1” is:
procedure MySecondDemo(cond: String);
var
S: String;
begin
S := "first";
if cond = "2" then S := "second";
MessageBox("The " + S + " link was clicked", "Second Demo", MB_OK + MB_ICONINFORMATION);
end;
It accepts a single string parameter. We can then use two different links, changing only the parameter from “1” to “2”:
First link:
<a href="hescript:demo1.MySecondDemo%7C1">This is the 1st link</a>
Second link:
<a href="hescript://demo1.MySecondDemo|2">This is the 2nd link</a>
Info
String parameters should only be used in links and JavaScript calls.
Using JavaScript #
You can use HEScript in conjunction with JavaScript.
Please refer to the exeoutput object API for calling HEScript from JavaScript.
Using PHP #
ExeOutput for PHP provides two built-in PHP functions for calling HEScript functions:
exo_runhescriptcom(string $script)
$scriptis the reference to the script’s name and the function to call.
string exo_return_hescriptcom(string $script, string $defaultvalue)
Please refer to the ExeOutput for PHP Internal Functions topic for samples.