Problem with Variable breakpoints

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Problem with Variable breakpoints

Post by sarver311 » Fri Sep 03, 2010 8:48 pm

I don' t know if it's broken or this is working as intended but I noticed an issue with Variable Breakpoints not working under certain scenarios.

Here are two code samples that illustrate when it works fine and when it doesn't.

Working Scenario:
I have a variable break set to StopScript=True The script basically loops through for a few seconds and once k is 10 it sets the variable to true and the variable breakpoint stops right at that moment.

Code: Select all

let>k=0
label>actionloop
  wait>.01
  let>k=%k%+1
  if>k=10
    let>StopScript=True
  endif
goto>actionloop
That works just fine. However as soon as I introduce a dialog into the mix the variable breakpoint ceases to function. This basically the same as the above script, the loop just begins as soon as you click the button but the script never stops when Stopscript=True. Also I tried this with modal and nonmodal versions of a dialog with same issue.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 255
  Top = 116
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 431
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSButton1: tMSButton
    Left = 148
    Top = 72
    Width = 75
    Height = 25
    Caption = 'StartLoop'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,StartLoop,OnClick,startloop
show>dialog1,r

srt>startloop
  let>k=0
  label>actionloop
    wait>.10
    let>k=%k%+1
    if>k=10
      let>StopScript=True
    endif
  goto>actionloop
END>startloop
Am I missing something?

Thanks!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Sep 04, 2010 4:55 am

AddDialogHandler>Dialog1,StartLoop,OnClick,startloop

should be

AddDialogHandler>Dialog1,msButton1,OnClick,startloop

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Sat Sep 04, 2010 5:33 am

Oops, I made a last minute change to the script before making this post so I can see how you would that was the only reason it wasn't working. Sorry for the confusion! If you fix my typo and try that script the problem still exists. I know for sure it is working too because I add a message right when the srt>startloop sub runs so i know it has started.

I made sure my variable breakpoint is spelled right and even tried everything uppercase, still nogo.

Try this and let me know if you observe the same problem.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 255
  Top = 116
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 431
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object StartLoop: tMSButton
    Left = 148
    Top = 72
    Width = 75
    Height = 25
    Caption = 'StartLoop'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,StartLoop,OnClick,startloop
show>dialog1,r

srt>startloop
  let>k=0
  messagemodal>the loop is about to start, lets see if the variable breakpoint works
  label>actionloop
    wait>.10
    let>k=%k%+1
    if>k=10
    
      let>StopScript=True
    endif
  goto>actionloop
END>startloop


User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Sep 04, 2010 2:00 pm

Perhaps I'm not understanding the purpose of the variable "StopScript". I assumed you were using it somewhere else in your script. If I step through your script in the editor, I see that "StopScript" gets set tp True. As far as I know you would then need to perform some action based on that value of "StopScript".

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 255
  Top = 116
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 431
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object StartLoop: tMSButton
    Left = 148
    Top = 72
    Width = 75
    Height = 25
    Caption = 'StartLoop'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,StartLoop,OnClick,startloop
show>dialog1,r

srt>startloop
  let>k=0
  messagemodal>the loop is about to start, lets see if the variable breakpoint works
  label>actionloop
  
  //JRL added the following 4 lines
    If>StopScript=True
      MDL>StopScript=%StopScript%
      Exit>0
    EndIf
  /////////////////////////////////////
    
    wait>.10
    let>k=%k%+1
    if>k=10
    
      let>StopScript=True
    endif
  goto>actionloop
END>startloop

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Sat Sep 04, 2010 4:33 pm

Ok, you know how in the debugger for macro scheduler there is an option called variable breakpoints? In there you set can set a value pair that tells macro scheduler to pause the script when that value has been reached. In this case when StopScript=True.

I was having an issue in another script where I couldn't get the variable breakpoint to pause the script. That is when I discovered the issue with the dialog. My other script is way to big and calls databases etc. so I just made the two sample scripts to illustrate that it works without a dialog and stops to work when there is a dialog in the script.

So when you run these scripts, go to your debugger and go into the variable breakpoint option and put stopscript=True. For the first script I posted it will pause the debugger once the value hits true, for the second one it will not.

Does that make more sense? Sorry for the confusion and thanks for the help!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun Sep 05, 2010 5:02 am

I see it now. Thank you for the explanation. It appears that "variable breakpoints" were introduced with version 12. Somehow I missed the boat and didn't know about them.

I now agree that variable breakpoints do not seem to work once a dialog is displayed. I even made the dialog non-modal then added a GoSub line immediately following the show> line and the script failed to pause when StopScript=10 . Place the Gosub immediately ahead of Show> and the script pauses as it should.

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Sun Sep 05, 2010 6:04 am

Thanks JRL! Yeah I hadn't messed with them much but had an entirely different problem where a variable breakpoint would come in handy then I could get it to work and thought I was crazy. Thanks for confirming it's not just much.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts