You can manage global variables using:
the SetGlobalVar and GetGlobalVar functions in HEScript.
the exo_setglobalvariable and exo_getglobalvariable functions in PHP.
Global variable names are unique and must contain only alphanumeric characters (without any space). In general, your global variables should never begin with "HE" because such variables may be used internally by ExeOutput for PHP.
Global variables may be persistent or temporary; a persistent variable is stored in the application, in other words the variable and its value are saved in the application's state file and loaded the next time the application is run. A temporary variable will exist only for the current session. You determine whether a variable is persistent or not when you set its value using the SetGlobalVar method.
Global variables are not shared between several running instances of an application, but you can force all of the instances to have the same global variables by calling the SynchronizeGlobalVar function.
Not all global variables are available in console applications: only HEPublicationFile and HEPublicationPath are used. Likewise, it is not possible to change the values of global variables in console applications.
|Global Variable Name||Description|
|HEPublicationFile||The full path to the application's .exe file (including filename)|
|HEPublicationPath||The full path to the folder that contains the application's .exe file (no filename). It will always include the path trailing backslash (e.g. C: MyPath** **).|
|HELasterrormessage||When an error occurs, this variable contains the error message.|
|DefWinTitle||The title of the main window.|
|HomePage||The index page's filename.|
|HEPubStorageLocation||The path where the application stores its data. You can customize it.|
|HEPubTempPath||The path to a temporary location where the application stores its external files temporarily. This will change each time.|
|HEPHPDataPath||The path to the virtual cache folder used for PHP files (includes the last trailing backslash).|
|HEPublicationDiskInfo||Contains the device ID returned by Windows of the USB disk on which the application EXE lies|
|CurPageTitle||The title of the page which is currently displayed.|
|FwdButtonEnabled||Is the forward button enabled? (true/false)|
|BackButtonEnabled||Is the back button enabled? (true/false)|
|HEStartCurrentDirectory||The current working directory (when you launch the EXE). Read this global variable instead of calling |
|HEPublicationOnUSB||Boolean (0 or 1). Tells you whether the application is on a USB drive or not. In order to be used, GetManualHardwareID(1) must be invoked first. For example, using this global variable lets you decide whether an application may be run or not.|
|isappterminated||Only accessible from PHP. This global variable is set to "1" when the application is terminated. Useful for an infinite loop in PHP to find out whether it should exit. See sample below|
<?php $storagelocation = exo_getglobalvariable('HEPubStorageLocation', ''); $file = $storagelocation.'myfile1.txt'; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); fclose($fp); ?>
procedure OnStartMainWindow; begin // When the main window is going to be displayed (just before the homepage is shown). SetGlobalVar("hesuppressjsdlg", "1", false); end;
For instance, use this PHP code in your loops:
if (exo_getglobalvariable("isappterminated", "0") == "1") break;
How to call HEScript procedures/functions?