Status: Draft

Debug your Code with Script Debugger

Desktop Studio helps you to test and troubleshoot your project.

It lets you:

  • Set breakpoints in the code to enable Step-by-step execution,
  • View the values of Local and Watch variables,
  • Execute code on the fly.


A project can be started in two different ways:

  • From Desktop Studio,
  • Via a shortcut.


Start via Shortcut

This is the standard way to launch an application in Production.

The shortcut generated by Desktop Studio (at export time) starts the Engine in Release mode (see Manage Project Environments).

Alternatively, it can be started in Debug mode by adding the command line argument: '-t 512' to the shortcut arguments
(see the “Desktop Agent & Studio - Installation Guide” for details of command line options).

If the project is started in Debug mode via a shortcut, Desktop Studio is not required. In this case, however, interaction with Desktop Studio is disabled.
Debugging will then be performed via the Control Pane V2.


Start from Desktop Studio

To start a project via Desktop Studio, you can use one of the following commands from the Main Menu or from the Debugger Toolbar:

RunStarts the project in Release mode (without debugger)
DebugStarts the project in Debug mode
Debug in Export modeStarts the project from the Export result in Debug mode

Working Directory

The working directory is mandatory to launch the project in Release or Debug mode.
This working directory must be write-enabled in order to host the log files. If the working directory is missing, the launch of Desktop Agent will fail.

By default, Desktop Studio sets the working directory in the folder containing the project file.

If the project file is opened from a Web URL or if it is located in a read-only directory, Desktop Studio uses a temporary working directory.
For example: C:\Users\< user login>\AppData\Local\Temp\


Manage Debug Options

Debug options can be managed when starting a project in Debug mode.

For this purpose, select Debug/Manage Debug options from the Main Menu or from the Debugger Toolbar.

The 'Manage Debug options' dialog is displayed.

The 'Debugger' tab lets you choose the Debugger that will be used:

This dialog also lets you specify whether you wish to automatically minimize Desktop Studio when running.

The Trace options tab lets you choose the trace level:

  • Trace level for the log files:
    • Trace events,
    • Detailed tracking of orders,
    • Simplified tracking of orders,
    • Tracking of the context data,
    • Tracking of the 'Extend Pilots',
    • Trace objects,
    • Trace all Event Win,
    • Trace messages (MESSBOX),
  • Trace level for the framework:
    • Log framework trace in file,
    • Capture screenshots.

The 'Technical options' tab lets you choose the technical trace level.

A technical trace provides information from Desktop Studio drivers.




Desktop Studio supports 'Step by step execution'. This enables code to be executed line by line.

To enter 'Step by step execution', execution must break on a breakpoint.

Manage Breakpoints

Breakpoints are set or removed on a script or XML block line in the Code Editor using the 'Toggle Breakpoint' command from the Main Menu or from the Debugger Toolbar:

  • If a breakpoint already exists on this line, it is removed,
  • Otherwise, it is set.

When a breakpoint is set, a indicator is set in the Indicator Margin and the line is highlighted in red:

Breakpoint Tool Window The Breakpoint tool window in the Editor Perspective displays a list of breakpoints already set.

Right-click to:

  • Navigate to the selected breakpoint,
  • Delete the selected breakpoint,
  • Delete all breakpoints.


Step by Step in the Code Editor

When a breakpoint is reached:

To resume execution, use one of the following commands from the Main Menu or the Debugger Toolbar:

Icon Command Shortcut Description
ResumeF5Continue execution until another breakpoint is reached
Step intoF11If on a line containing a method call, this command will enter the method and break again on the first line of code inside the method.
Use Step Into to see what happens inside a method call.
Step overF10Execute the entire method call and break on the next line of code in the current method.
Use Step Over to execute the entire method and continue in the current code block.
Step outShift+F11Execute the rest of the current method and return to the calling method.
Execution will break at the return point in the calling function.
Resume and BreakShift+F10Continue execution until another line of your code is executed.
This command is particularly useful for halting execution when a callback function is called.
StopShift+F5Stop project execution.


Break All

It is possible to break execution even if no breakpoint is reached.
To do this, use the 'Break all' command from the Main Menu or from the Debugger Toolbar:

Break allBreaks execution on the next executed line.

This command is particularly useful when you want to find out what code is currently being executed (in other words, in infinite loops).


Manage Watches

Watches tool window

The Watch tool window in the Editor Perspective displays a list of watched variables.

A line is displayed for each variable. It shows the following information:

  • The variable name,
  • The variable value,
  • The variable type (Integer, Boolean, String, Object, Array, and so forth).

The value and type data are only filled when the project is running in Debug mode and when execution is halted at a break.

Each variable line is precedeed by an indicator that shows its type:

Simple Variable
Object or Array
Properties or Method
Undefined

By right-clicking the desired value, you can :

  • Delete a watch,
  • Copy the variable value to the clipboard.

To add a watch in the 'Watch tool window':

Note:

  • A watch can be added at any time, whether or not the project is running.


View Local Variables

Local Tool Window The Local tool window in the Editor Perspective automatically displays a list of variables local to the current execution context.

It is only filled when the project is run in Debug mode and when execution halts at a break.

A line is displayed for each variable. It shows the following information:

  • The name,
  • The value,
  • The type (Integer, Boolean, String, Object, Array, and so forth).

Each variable line is precedeed by an indicator that shows its type:

Simple Variable
Object or Array
Properties or Method
Undefined

Right-click the desired value to:

  • Add a variable to the watches,
  • Copy the variable value to the clipboard.


Use Call Stack

Call Stack tool window When execution halts on a break, the Call Stack tool window in the Editor Perspective displays the call stack.
The call stack is the set of nested function calls that are currently running and waiting to return.

The Call Stack window displays the name of each function:

  • The 'line number' where occurs the call,
  • The function name (if known),
  • The script file containing the function.

By double-clicking a function's line, you can navigate to the corresponding line in the script file.


This article is being updated. Stay tuned for more information.

You can also execute code on the fly.