External functions referenced in your structure definition files must be defined in separate files. Hex Editor Neo supports functions written in JavaScript and VBScript.
Use the following syntax to attach a script file to the structure definition file:
#pragma script(path-to-script-file)
Path-to-script-file is a string containing the absolute or relative (to the structure definition file) path to a script file. Hex Editor Neo uses the extension of the file name to determine the language. You cannot use more than one language in a single definition file. Remember that when you use an #include preprocessor directive to include another structure definition file, its contents is physically included, so make sure you do not use different scripting languages in included files.
Hex Editor Neo recognizes files having extension "js" as writtin in JavaScript and "vbs" as written in VBScript.
As with included files, Hex Editor Neo automatically rescans a file if it is modified outside the editor.
Note: you cannot mix Javascript and VBScript files in the same structure definition file.
functions.js:
function f()
{
return 10;
}
structure.h:
#pragma script("functions.js")
public struct A
{
char array[f()];
};
In addition, starting with version 4.92, javascript code may be specified in the structure definition file using the new javascript keyword:
javascript
{
function f()
{
return 10;
}
};
public struct A
{
char array[f()];
};
The number of javascript blocks is not limited. All blocks are processed before any structure is bound, so all functions declared in these blocks are always visible to any structure, regardless of the place where you define them.
You may combine the #pragma script and javascript keyword with one exception: you cannot mix Javascript and VBScript files. If you reference a VBScript file, all javascript blocks will be ignored.