Programmatically add a watch expression to the debug watch window

A user may want to add a particular variable or expression to the Visual Foxpro debug watch window

Here’s some code to do it.

The debugger can read/write a particular debug config file. The default is stored in the fox resource file. Or you can choose File->Save Configuration to save various configurations.

Try saving a config file and examining it to see the various options available.

This code assumes that you already have a FOXUSER record for WATCHEXPR.

TEXT TO myvar

DBGCFGVERSION=4

WATCH=_vfp.Caption

WATCH=myvar

BPMESSAGE=ON

EVENTWINDOW=ON

EVENTFILE=

ENDTEXT

USE SET("Resource",1) AGAIN SHARED

LOCATE FOR id="WATCHEXPR" AND !DELETED()

REPLACE data WITH CHR(4)+CHR(0)+myvar,ckval WITH VAL(SYS(2007,myvar))

USE

ACTIVATE WINDOW watch

43646