HEScript scripts are especially designed to control the publication's behavior and to communicate with the environment (runtime module, Windows...).
You have a lot of internal functions that can be called from within the HEScript script functions/procedures.
Notes:
More functions may be added with the next runtime modules releases. Please check the www.htmlexe.com website for the latest versions.
If you have ideas about functions, feedback or bugs to report, please go to our forums and post them. You can also contact technical support.
A lot of internal functions are not listed here at this time (but may be used in system HTML pages for instance). Please ignore them or contact us for more information.
Please have a look at the samples, articles and the knowledge base at www.htmlexe.com
List and descriptions of internal script functions
Interface related:
Function name
Description & prototype
Parameters, example, remarks
MessageBox
Displays a message box (similar to the Windows API MessageBox)
Flags: set of bit flags that determine the contents and behavior of the box. More information here. May be MB_OK, MB_OKCANCEL, MB_YESNOCANCEL, MB_YESNO, .... plus MB_ICONSTOP, MB_ICONINFORMATION, MB_ICONWARNING...
Result (integer): may be IDOK, IDCANCEL, ..., IDYES, IDNO depending on the button selected by the user.
OpenIt: if false, the navigation panel is hidden (whatever the value of Id). Otherwise it is displayed.
Possible ID values:
1: Search.
2: TOC (Table of Contents)
3: Favorites
4: Favorite Manager
IMPORTANT: the navigation panel must have been enabled in HTML Executable! Otherwise you will get problems.
GetLeftPanel
Returns the index of the current navigation panel.
function GetLeftPanel: Integer
Result: index of the panel currently displayed.
See possible values above. Returns 0 if no panel is displayed.
ShowAboutBox
Shows the About box.
procedure ShowAboutBox;
Navigation related:
Function name
Description & prototype
Parameters, example, remarks
GoToPage
Displays (or executes) the specified URL.
procedure GoToPage(const Name, Window: String);
Name: partial or full URL to display. This can be a single HTML page, a full URL (you can use the ghe://heserver/ internal protocol, or standard protocols like http, ftp, etc...) or even a hescript:// command.
Window: do not use at this time (internal use only). Leave blank "".
UseMapID
Displays the HTML page whose map ID corresponds to ID.
IsStored: indicates whether the global variable is a persistent one, i.e. it is stored in the publication's state data file and restored when the publication is run again.
Use global variables to store or exchange data between different scripts.
GetGlobalVar
Gets the value of a global variable.
function GetGlobalVar(const Name, DefaultIfNotFound: String): String;
Name: name of the global variable.
DefaultIfNotFound: what the function should return if the global variable is not found.
Result: the value of the variable if it exists, otherwise the value of DefaultIfNotFound.
Publications use a lot of internal global variables. You can get a list of interesting ones here.
SynchronizeGlobalVar
If several instances of a publication are running, call this function to force all global variables (only the persistent ones: see above) to get the same value as the ones of the publication who made the call.
procedure SynchronizeGlobalVar;
Persistent global variables can be used to share data between several instances of a publication.
Result: the value of the resource string, or blank if not found.
GetManualHardwareID
Returns a unique system ID based on hardware specifications.
function GetManualHardwareID(method: integer): String;
method: method identifier to compute the unique ID.
0: serial number of the first hard disk 1: manufacturer-allocated number used to identify the physical media 2: CPU specifications such as CPU ID 3: manufacturer-allocated number of first hard disk.
ClearCache: True to clear the cache or False to clear the history.
HTML related:
Please note that some of these functions are only designed for HTML Viewer publications, as they try to compensate the lack of JavaScript support. If you work with IE Browser publications, then try to use JavaScript instead.
Function name
Description & prototype
Parameters, example, remarks
ShowHTMLBlockID
Provides an easy way to control the display of a block of HTML text. Typical blocks that can be controlled include <div>, <p>, <ul>, <form>, <table>, etc. The block tag must contain an ID= attribute to identify it.
Controlname: name of the control or form field. There is no need to indicate which form the field belongs to. However your controls should have unique names in a HTML page.
PropertyName: which property should be set. Must be Text if the control is a form field.
PropertyValue: the new value to give to the property.
This function works only in HTML Viewer publications! You can use this function at any time, it does not require a form to be submitted first contrary to the previous functions.
GetFormControlValue
Gets the value of a form field, or a property of an ActiveX control (use of the PANEL tag).
function GetFormControlValue(const ControlName, PropertyName, DefValue: String): String;
Controlname: name of the control or form field. There is no need to indicate which form the field belongs to. However your controls should have unique names in a HTML page.
PropertyName: the property whose value should be read. Must be Text if the control is a form field.
DefValue: the value if the control is not found.
Result: returns the value of the property in string format.
This function works only in HTML Viewer publications!
CallFormControlMethod
Calls a method of an ActiveX control (use of the PANEL tag). Experimental use at this time!
URL: url to the page that should be displayed. It can be a virtual path to a compiled page or a full URL.
Width, Height: width and height of the popup window (in pixels).
Left, Top: x and y screen coordinates of the top-left corner (in pixels).
IsModal: always set the value to false.
RedirectLinksToMain: whether you want the popup window to redirect all hyperlinks to the main window (when a user clicks a link, the page is displayed in the main window). Could be useful for website contents.
To create a screen-centered popup, set both Left and Top to -1.
URL: url to the page that should be displayed. It can be a virtual path to a compiled page or a full URL.
Width, Height: width and height of the popup window (in pixels).
Left, Top: x and y screen coordinates of the top-left corner (in pixels).
IsModal: always set the value to false.
RedirectLinksToMain: whether you want the popup window to redirect all hyperlinks to the main window (when a user clicks a link, the page is displayed in the main window). Could be useful for website contents.
Parameters: additional parameters for creating the popup. Possible parameters include: parentexplicit or parentismain.
Returns the name of the popup which has the focus. function ActivePopupName: String;
ClosePopup
Closes a popup window.
procedure ClosePopup(const Name: String);
Name: name of the popup window that should be closed.
CloseAllPopups
Closes all popup windows that are visible.
procedure CloseAllPopups;
External Programs/Files
Function name
Description & prototype
Parameters, example, remarks
OpenFile
Opens an external document or program file.
function OpenFile(const Filename, Parameters: String; State: Integer): Integer;
Filename: full path to the file you want to open or run.
Parameters: optional command line parameters.
State: window state. May be SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED, SW_HIDE...
Result: successful if greater than 31.
For executable files, you may also use RunAProgram.
UnpackTemporaryResource
Extracts a file from the publication's data (it must have been compiled) to a temporary file and returns the path to this file. The file is normally removed when the publication closes.
function UnpackTemporaryResource(const SourceName: String): String;
SourceName: virtual path to the file you want to extract from the publication's data.
Result: full path to the extracted temporary file on the user hard disk.
You can use this function to extract and run special files that cannot be handled by the publication, such as video, executable, etc... Useful with OpenFile.
ExportAFile
Same as the previous function, except that it will display a Save As dialog box, and the file is not temporary. Acts like when you download a file from the Internet.
function ExportAFile(const SourceName: String; PromptTitle, DefFilename: String): String;
SourceName: virtual path to the file you want to extract from the publication's data.
PromptTitle: the title of the Save As dialog box.
DefFilename: the default filename that should be used. It can be "*.*".
Result: full path to the final unpacked file.
The file is not removed! Useful if you want to let your end users "download" files from your publication.
GetTemporaryFilename
Returns the full path to a temporary file.
function GetTemporaryFilename: String;
This function may be useful for functions like SaveFormResultsToFile.
This function will replace the current registration information items with the provided ones. For security reasons, it does not check the validity of the key: at the next startup, the publication will run with the certificate whose key was made for.
ActivateCertificate
Forces the trial publication to activate the certificate that matches the current registration items saved by RegisterPub.
function ActivateCertificate: String;
Should only be used after a call to RegisterPub, and followed by ExitPublication.
Returns the name of the selected certificate. Blank if no certificate matches.
GetCurrentCertificate
Returns the name of the current certificate. Only working if you have Trial publication.
function GetCurrentCertificate: String;
SetDefaultCertificate
Sets the current certificate to default one.
procedure SetDefaultCertificate;
This function causes the publication to come back to the Default certificate. If the default certificate has an expiration period, this period is automatically expired.
MD5OfAString
Gets the MD5 hash sum of the specified string.
function MD5OfAString(const Str: String): String;
Str: string you want to get the MD5 sum of.
Result: string format of the MD5 sum.
MD5OfAFile
Gets the MD5 hash sum of the specified file.
function MD5OfAFile(const Path: String): String;
Path: full path to the file you want to get the MD5 sum of.
Result: string format of the MD5 sum.
InputBox
Prompts your end users for a query (a dialog box is shown)
function InputBox(const Query, Title, Default: String): String;
Query: the prompt text. Tells your end users what you are asking.
Title: title of the dialog box.
Default: the default value to display in the field.
Result: returns what end users answered or a blank value if they chose "Cancel".
ParamStr
Returns the index-th parameter passed to the program using the command line.
function ParamStr(index: Integer): String;
Index: index of the parameter you want to obtain.
Note: use double quotes to wrap multiple words as one parameter (such as long file names containing spaces).
StartTimer
Starts a timer to trigger an event, either one time or repeatedly, after a measured interval. Write the code that you want to occur at the specified time inside the UserMain's OnTimer function event.
TimerName: name of the custom timer. NOT CURRENTLY USED. Just leave blank.
Interval: determines the amount of time, in milliseconds, that passes before the timer initiates another OnTimer event. For example 1000 for one second. Note: A 0 value is valid, however the timer won't call an OnTimer event for a value of 0.
StopTimer
Stops a timer that was created by StartTimer.
procedure StopTimer(const TimerName: String);
TimerName: name of the custom timer. NOT CURRENTLY USED. Just leave blank.
StrAnsiToUtf8
Converts a normal ansi string to a UTF8 encoded string.
function StrAnsiToUtf8(const Str: String): String;
Str: the string you want to convert.
StrUtf8ToAnsi
Converts a UTF8 encoded string to a normal ansi string.
function StrUtf8ToAnsi(const Str: String): String;
Str: the string you want to convert.
StrEncodeBinHex
Encodes binary data in Str as BINHEX. The function returns the BINHEX encoded data as string, without any linebreaks.
function StrEncodeBinHex(const Str: String): String;
Str: the string you want to convert.
StrDecodeBinHex
Decodes BINHEX data in Str into binary data. The function returns the binary data as string. The Str string may contain linebreaks and control characters, these will be stripped.
function StrDecodeBinHex(const Str: String): String;
Str: the string you want to convert.
IsIEEngine
Indicates the type of publication: HTML Viewer or IE Browser.
function IsIEEngine: Boolean;
Returns True if the publication is an IE Browser one. This function is used internally.
SetClipboardText
Set the contents of the Windows Clipboard to the text from Data. procedure SetClipboardText(const Data: String);
Data: the text data to put in the clipboard.
GetClipboardText
Retrieves the contents from the Windows Clipboard as text. function GetClipboardText: String;
procedure Beep; function Trim(const S: string): string; function TrimLeft(const S: string): string; function TrimRight(const S: string): string; function GetCurrentDir: string; function SetCurrentDir(const Dir: string): Boolean; function ExpandFileName(const FileName: string): string; function ExpandUNCFileName(const FileName: string): string; function ExtractRelativePath(const BaseName, DestName: string): string; function ExtractFileDir(const FileName: string): string; function ExtractFileDrive(const FileName: string): string; function ExtractFileExt(const FileName: string): string; function ExtractFileName(const FileName: string): string; function ExtractFilePath(const FileName: string): string; function ChangeFileExt(const FileName, Extension: string): string; function FileSearch(const Name, DirList: string): string; function RenameFile(const OldName, NewName: string): Boolean; function DeleteFile(const FileName: string): Boolean; function CreateDir(const Dir: string): Boolean; function RemoveDir(const Dir: string): Boolean; function CompareStr(const S1, S2: string): Integer; function MCompareText(const Str1, Str2: String): Integer; // Same as AnsiCompareText function CompareText(const S1, S2: string): Integer; function IncludeTrailingBackslash(const S: string): string; function Format1(const Format, S1: String): String; (similar to Format) function Format2(const Format, S1, S2: String): String; (similar to Format) function Format3(const Format, S1, S2, S3: String): String; (similar to Format) function Format4(const Format, S1, S2, S3, S4: String): String; (similar to Format) function SysErrorMessage(ErrorCode: Integer): String; function Ord(C: Char): Byte; function Copy(S: String; Indx, Count: Integer): String; function Length(s: String): Longint; function Lowercase(s: string): String; function StrGet(S: String; I: Integer): Char; function StringOfChar(c: Char; I : Longint): String; function StrSet(c: Char; I: Integer; var s: String): Char; function Uppercase(s: string): String; function strExtract(S: String; Column: Integer; const Separator: String): String; procedure Delete(var S: String; Indx, Count: Integer); procedure Insert(Source: String; var Dest: String; Indx: Integer); function Pos(SubStr, S: String): Integer; function StrToIntDef(s: string; def: Longint): Longint; function StrToInt(s: string): Longint; function IntToStr(i: Longint): String; function Now: TDateTime; function Date: TDateTime; function Time: TDateTime; function DateToStr(Date: TDateTime): string; function FormatDateTime(const Format: string; DateTime: TDateTime): string; function StrToDate(const S: string): TDateTime; function DayOfWeek(Date: TDateTime): Integer; function FileExists(const FilePath: String): Boolean;
Some Delphi classes like TStringList, TMemoryStream are also supported.