Not available in exe.
deb[+|-] [speedMS]
speedMS - time, in milliseconds, to wait before executing a statement. Default: -1 (infinite).
Default | Start debug/step mode. |
+ (QM 2.3.1) | Start debug mode and run until a breakpoint, then start step mode. |
- | End step mode and run until a breakpoint. Does not start/end debug mode. Does not use speedMS. |
Sets debug mode for current thread (running macro).
Also you can run current macro in debug mode from the Debug menu. Then don't need deb.
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 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 breakpoints and menu Debug -> Options -> Break on error. Read more below. To start/end step mode, also can be used Debug menu/toolbar items. 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 a 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 - runs the macro (or continues) not in step mode, but stops (starts step mode) at the statement that contains the text cursor (caret). Also stops at breakpoints.
Run to Breakpoint - runs the macro (or continues) not in step mode, until a breakpoint or until the end. The same as deb+ or deb-.
End - end threads that are being debugged, and turn off the debug mode.
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 breakpoints.
Also you can use breakpoints. To add or remove a breakpoint, middle click the selection bar or use the Debug menu. Breakpoints are marked with brown circle markers in the selection bar. A breakpoint is similar to deb. However breakpoints are activated only in debug mode, ie if the macro executed deb or deb+ before, or you started it from the Debug menu. Breakpoints disappear when you close the macro or exit QM.
You should not put 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 (Run to Breakpoint) 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.
In menu Debug -> Options you can 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 Debug -> Options -> Show Debug Window is checked, QM will show Debug window when starting debug mode. Read more below.
You can place deb in several places in macro. It allows you to debug parts of macro in different speeds or turn on/off step 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 debug functions.
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.
Background colors:
blue - member variables (this);
green - parameters;
wheat - thread variables;
yellow - variables inherited from sub-function parent or application folder main function.
Text colors:
purple - changed in previous step;
gray - hidden.
Variables are shown only in step mode (and not if speedMS used).
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