External functions referenced in your structure definition files must be defined in separate files. Device Monitoring Studio supports functions written in JavaScript.
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. Only JavaScript external files (with any extension) are supported.
As with included files, Device Monitoring Studio automatically rescans a file if it is modified outside the editor.
function f()
{
return 10;
}
#pragma script("functions.js")
public struct A
{
char array[f()];
};
javascript
KeywordIn addition, JavaScript code may be specified in the structure definition file using the 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.