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

External Functions

Device Monitoring Studio allows you to use external functions in expressions. External functions are defined in script files, attached to structure definition files using the #pragma script preprocessor directive.

An external function accepts zero or more parameters and must always return a value (“void” functions, or procedures are not supported). External function must be written in JavaScript.

Device Monitoring Studio automatically performs parameter type conversion when the function call is made. Although, make sure the value returned by the function is of correct type, as Device Monitoring Studio expects a value of a given type in several places, such as in array declaration:

functions.js:
function GetArraySize()
{
    return 11/2;
}
structure.h:
#pragma script("functions.js")

struct A
{
    int array[GetArraySize()];         // error here: script returns a floating-point number, integer expected
    int array[int(GetArraySize())];    // correct
};