Skip to content

Introduction to Scripting with HEScript - Extend Functionality

ExeOutput for PHP applications are actually script-driven and they feature a built-in script engine. An application is therefore managed by a collection of scripts that were generated and compiled into p-code by ExeOutput for PHP. When an application is run, its runtime module executes the different scripts in order to simulate a web browser where end users can view your PHP and HTML pages, and to respond to the actions performed by your end users.

You can therefore extend the functionality of applications by writing and calling your own script functions. This feature allows you to do almost anything you want.

Info

Note that you are not obliged to work with scripting in order to use ExeOutput for PHP and compile applications. Scripting is for advanced users who want to have full control over their applications.

About the script language named HEScript

The script language used by ExeOutput for PHP is called HEScript. It is based on the Object Pascal language syntax (similar to Embarcadero® Delphi and FreePascal) with some minor changes.

Contrary to JavaScript and PHP, you cannot write HEScript functions directly into HTML and PHP pages because HEScript scripts need first to be compiled into pseudo-code as explained above. That's why you have to use the User Script Manager to write and manage your scripts.

A simple script example:

// UserMain
// This script contains special functions related to some of the events triggered by the application.
 //You can then optionally add new commands.

function OnBeforeNavigate(NewURL, TargetFrame: String): Boolean; 
begin 
 //Before the application displays a page. Set Result to True to stop the operation.
Result := False;
end;

procedure OnNavigateComplete;
begin
 // When a page has been displayed.
end;

A script file is a group of procedures or functions. Each script file has a unique name; each procedure/function has a name following these rules:

  • only alphanumeric characters may be used, no space.

  • each name must be unique in a given script file, but you can have two different script files that contain procedures or functions with the same name.

Some important notes

  1. Script files act like namespaces. When you call or assign a procedure/function to an event, you will need to specify the script name followed by a dot (.) and the name of this procedure/function, i.e. [scriptname].[functionprocedurename]. Example: UserMain.OnNavigateComplete
  2. Each script is managed by an independent script engine so you have to use global variables in order to exchange data between scripts.
  3. The use of local variables is possible but not recommended.