Debugging xDialog code can be hard, but here's one trick that can help. This enables you to cycle through the controls of your xDialog, and then to run the debugger when you want to debug a specific piece of code (note that you can place debug statements anywhere).
Here it is - copy it and play with it!
- Eric
Here it is - copy it and play with it!
- Eric
Code:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Xdialog - demonstrate how to turn debugging on/off when running Xdialog cTitle = "Xdialog Demo" dim cVar1 as c dim cVar2 as c dim nVar3 as n dim n1 as n = 1 dim n2 as n = 2 dim lDebug as L = .f. 'Make sure this starts as false dim dlgtext as c = <<%dlg% {lf=1}; {wrap=60} {frame=1,1:Here's the demo...} {region} {lf=2}; Run this Xdialog. When you want to start the debugger, click the check box and then move the cursor to any field to give it focus.; {lf=1}; {sp=3}(lDebug) Check this to turn debugger on; {lf=3}; {region} First field: | [.25cVar1!c1_*] | Track all events; Second field: | [.25cVar2!c2_*] | Track all events; Third field: | [.15nVar3!nVar3] | Track only change event; Display n1: | {text=n1} Debug: | {text=lDebug} {lf=2}; {endregion}; {lf=4}; {region} {justify=center,center} <25,2Button 1!But1> <25,2Finished!Finished> {endregion}; {endregion}; %dlg% dim dlgcode as c = <<%code% trace.writeln("Debug:"+lDebug+", a_dlg_button:"+a_dlg_button) if left(a_dlg_button,3) = "c1_" trace.writeln("c1 event") 'Use this IF statement to conditionally debug your code if lDebug 'come here when lDebug is True debug(1) n1 = 5 n2 = n1*6 + 78 n1 = 34 lDebug = .f. 'Turn debugger off so you can Run again end if a_dlg_button = "" end if if left(a_dlg_button,3) = "c2_" trace.writeln("c1 event") if lDebug 'come here when lDebug is True debug(1) n1 = 34 n2 = n1/3 + 3 n1 = 34 end if a_dlg_button = "" end if if a_dlg_button = "nVar3" trace.writeln("c1 event") if lDebug 'come here when lDebug is True debug(1) n1 = 1 n2 = n1 end if a_dlg_button = "" end if %code% dim cResult as c cResult = ui_dlg_box(cTitle,dlgtext,dlgcode) end ''''''''''''''''''''''''''''''''''''''''''''''''''''''''