General functions

This chapter is dedicated to general purpose functions that are used for general tasks like:

  • Script debugging
  • Progress reporting (for slow script operations)

Script renaming

It may be of interest to rename an instance of a script to a more unique name. For example, a workspace may have several instances of the UART protocol decoder scripts, each one targeting a different channel. If they all keep their default name, that is: “UART”, then it’s impossible to know which decoder is for which channel. For that particular reason, a script renaming function is provided so that at any given moment, a script can rename itself to a more “unique” name.

If we keep the example of the multiple UART decoder scripts, one solution would be to call the script renaming function in the GUI evaluation function, which is the moment where we know exactly what channel is targeted by that script.

The different UART decoders could then be renamed:

  • UART on CH1
  • UART on CH2
  • UART on CH3
  • etc…

The script renaming function is presented below


Description: This function renames the instance of the script. This temporary name changing does not affect the hard coded name of the script which is defined via meta-information tags (see chapter 2).


  • “script_name”: The new script of the name. This name will totally replace the script

Context: Global

Progress reporting


This function provides the user with a progress indication for slow operations (like decoding a very big amount of logic signals). This function should be called periodically (as often as deemed necessary). Calling the report_progress() function multiple times with the same progress_percentage value will have no effect (only a progress_percentage value different that previous one will be considered). It is highly recommend to implement this function in your script, for each and every entry-point function.


function on_decode_signals(resume)
  for (int i = 0; i < total_samples_count; i++)

    Your slow, time consuming decoding code goes here

Context : Global

Console messages


Description: This function prints the message msg in a console box in ScanaStudio. sample parameter is optional. If sample is defined, the console message will be displayed as hyperlink linked to the provided sample number. If the user clicks on that hyperlink, ScanaStudio’s waveform will center on that specific sample. This function is intended for debugging phase of a script, that being said, it may be used to display messages to the script’s end user if it does not fit elsewhere.


ScanaStudio.console_info_msg("A simple message");
ScanaStudio.console_info_msg("My variable =" + variable);
ScanaStudio.console_info_msg("A simple message linked to a sample", 50000);

Context : Global


Description: This function is identical in operation to ScanaStudio.console_info_msg(). The only difference is the way messages will be presented to the user as a “warning messages”.

Context : Global


Description: This function is identical in operation to ScanaStudio.console_info_msg(). The only difference is the way messages will be presented to the user as an “error messages”.

Context : Global



Description: This function formats a number in engineering notation. For example, ScanaStudio.engineering_notation("1500",3) would return “1.50 k”


  • number: The number to be formatted
  • digits: The number of digits (Please note that the minimum allowed number of digits is 3).

Return value: Returns text containing formatted number along with engineering prefix.

Context: Global