How does scripting work?
|Firmware Version||3.x, 4.x, 5.x, 6.x
Scripting support in the Gocator allows you to provide code to extend the existing measurement tools. PicoC is used as the scripting engine, which is a very small C interpreter, suitable for embedded devices. The language is very similar to C, with these notable differences:
- Explicit type casting (e.g., (int)afloat) is not supported. Values are cast implicitly.
- Tertiary operation (a ? b : c) is not supported.
- The “const” keyword is not supported.
The scripting language allows the definition of functions; everything outside of a function definition is executed in order of parsing. The script is executed once when a full set of real measurements are available. Only one script tool can be added to a job file, and the script is always executed last in a program.
The script tool can only access tool measurements (not features or data), stamp information (frame, time, encoder, inputs, etc.), and runtime variables. The script tool can also save scalar values to memory for future frame use (such as adding measurement values from previous scans).