Debug from middle of Script

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury, Rain

Post Reply
Danton
Newbie
Posts: 11
Joined: Thu Aug 26, 2010 12:04 am

Debug from middle of Script

Post by Danton » Thu Aug 08, 2019 7:48 am

I'm trying to debug a script. I'm repeatively getting stuck at the same page of an application.
I want to skip the first steps, and test from the point the script is getting stuck. I have tried stepping through the code in the editor but that does not seem to work as the application is in the background (as i'm in the editor) I cant get the debug to see the application in debug mode.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 459
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Debug from middle of Script

Post by Dorian (MJT support) » Fri Aug 09, 2019 1:03 pm

You could try the Refocus Windows option (>Debug >Refocus Windows / ALT-df) but there's no guarantee that this can cope mid-keystroke.

You could put a breakpoint after your first section of code. >Debug >Insert BreakPoint / ALT-di

Maybe also put a SetFocus after the breakpoint to ensure the correct window gets the focus. You can then run to breakpoint over that block of code, and then step through the bits that need more detailed examination.

This mentions the conundrum and some workarounds:
http://www.mjtnet.com/blog/2009/05/19/m ... debugging/

Another option is to turn on logging. You can even log all the variable, although this will result in a huge logfile.

Let>_DUMP_VARS=1
Let>_DUMP_VARS=0
Always accepting custom script commissions. Message me or go here

Danton
Newbie
Posts: 11
Joined: Thu Aug 26, 2010 12:04 am

Re: Debug from middle of Script

Post by Danton » Fri Aug 09, 2019 9:06 pm

Thanks for the tips.


I ended up doing the following.

Simply commenting out the first few subroutines that I know work so the subroutine I'm testing is executed first.
Putting a wait in the script before the critical step so I could place the application in the state before the failing step. I did have to temporarily manually define some variables that would normally be captured in previous subroutines.

Using messagemodal to display the value of variables that had been captured/used. This does two things allows me to pause the script so I can stop going down a path I don't want and of course confirms if the script is capturing the variable as expected.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 459
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Debug from middle of Script

Post by Dorian (MJT support) » Mon Aug 12, 2019 12:23 pm

I employ both those methods very frequently.
Always accepting custom script commissions. Message me or go here

Post Reply