Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

Attaching Scripts

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.

Examples

functions.js
function f()
{
    return 10;
}
structure.h:
#pragma script("functions.js")

public struct A
{
    char array[f()];
};

javascript Keyword

In 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.