Set debug mode

Syntax

deb[+|-] [speedMS]

 

Parameters

speedMS - time (milliseconds) to wait before executing a statement. Default: -1 (infinite).

 

Options:

Default Start debug/step mode.
+ (QM 2.3.1) Start debug mode and continue. Will start step mode at first breakpoint.
- Continue. It does not start and does not end debug mode. Does not use speedMS.

 

Remarks

Sets debug mode for current thread (running macro).

 

Also you can run current macro in debug mode using menu Run->Debug -> Step, Run to Cursor, or Continue. Then deb is not necessary.

 

In debug mode you can execute statements in steps, see variables, etc. While a thread is running in debug mode, several buttons are added to the toolbar, and optionally Debug window is shown.

 

In debug mode, the thread can run in step mode or not. In step mode, before each statement the thread waits speedMS milliseconds. If speedMS is omitted or -1, waits until you click one of Run->Debug menu items or toolbar buttons.

 

deb sets step mode. deb- ends step mode. deb+ also ends step mode. To set step mode also can be used temporary breakpoints and 'Break on error' menu items. Read more later. To end step mode, also can be used menu/toolbar items (Continue and other). Using all these features, you can execute some parts of macro in step mode, and other parts not in step mode.

 

Statements in not expanded folders are executed not in step mode. This makes debugging easier because skips System functions and other low level functions, unless you expand the folder where the function is (or use "Step Into" button).

 

Menu/toolbar items:

 

Step - executes the statement that is marked with a yellow arrow, and stops at the next statement. Then marks the executed statement with a green marker. If the statement calls an user-defined function, opens the function. Skips functions that are not in expanded folders.

 

Step Into - the same as above, but does not skip functions that are not in expanded folders.

 

Step Out - continues not in step mode, but stops when the function returns. Usually stops at the next statement in the caller function.

 

Run to Cursor - continues not in step mode, but stops at the statement that contains the text cursor.

 

Continue - continues not in step mode. The same as deb-.

 

End - end threads that are being debugged, and turn off the debug mode.

 

If after Continue, Run to Cursor or Step Out the thread encounters deb or a temporary breakpoint, it stops there.

 

If speedMS is >= 0, before each statement the thread waits for minimum speedMS milliseconds.

 

While the thread is waiting before executing a statement, it is not completely blocked. It allows to call callback functions, process dialog messages, COM events, etc. These callback functions then run not in step mode, even if they call deb or contain temporary breakpoints.

 

Also you can use temporary breakpoints. To add or remove a temporary breakpoint, middle click the selection bar or use the Run->Debug menu. Adding a temporary breakpoint is similar to inserting deb. However temporary breakpoints are activated only in debug mode, ie if the thread executed deb or deb+ before, or you started it from the Run->Debug menu. They disappear when you close the macro or exit QM. They are marked using brown markers.

 

You should not put temporary breakpoints on some flow control statements (err, empty case, etc), because there they may behave not as you expect. Breakpoints in lines that are not executed at run time (comments, declarations, directives, etc) break at the next statement.

 

In debug mode, the debug hotkeys (F5, etc) are temporarily registered as global hotkeys and work regardless whether QM is active. Hotkeys F5 (Step), Ctrl+F5 (Continue) and Shift+F5 (Run to Cursor) are always available in QM window. For example, you can press F5 to run the current macro in debug step mode, or Ctrl+F5 to run it in debug mode and stop at the first breakpoint.

 

You can check some Run -> Debug menu items 'Break on errors' or 'Display errors'. They set some options that are active in debug mode. If 'Break' checked, stops (starts step mode) on run-time errors. If 'Display' checked, displays handled errors in QM output.

 

If menu Run -> Debug -> Show Debug Window is checked, QM will show Debug window when starting debug mode. Read more below.

 

Tips

You can place deb in several places in macro. It allows you to debug parts of the macro in different speeds, or temporarily turn off the debug mode.

If you want to debug only certain message in dialog box procedure, don't forget to place deb- when leaving the code.

 

See also: other debugging commands.

 

The Debug window

Function call stack

 

At the top is the current function. At the bottom is the thread entry function.

 

You can click a function to see its variables. Double click to open.

 

Variables

 

Background colors:

blue - member variables (this);

green - parameters;

wheat - thread variables;

gray - special global variables.

 

Text colors:

purple - changed in previous step;

gray - hidden.

 

Variables are shown only in manual step mode (when speedMS is omitted or -1).

 

Examples

deb ;;set debug mode; stop before each statement
deb 500 ;;set debug mode; wait before each statement for minimum 500 ms
deb 0 ;;set debug mode; don't wait before statements but mark them while they are executed 
deb- ;;continue; ignored if not in debug mode
deb+ ;;set debug mode and immediately continue