From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Breakpoints ignored

I am trying to diagnose a problem with a script but have found some odd behaviour with breakpoints.

 

I have a script that calls another one using ScriptStart. I have put a breakpoint in the first script and another in the second script so that I can move line by line in the second script. The first loop around and all behaves as expected. However, on all following loops the second breakpoint is ignored.

 

I have tried all manner of combinations, even just putting a breakpoint in the second script and it will be ignored after the first loop around.

 

Can anyone tell me how I can reliably break a script on every loop through please?

 

Regards,

 

Simon.

0 Kudos
Message 1 of 6
(4,871 Views)

I think DIAdem will not stop on breakpoint startet with ScriptStart.

 

Try to use scriptinclude instead.

 

Assume we have a file foo2.vbs with the following content.

Option Explicit

sub foo2()
  MsgBox "foo2"
end sub

Assume we want to call foo2 from another vbs called foo1.vbs

Option Explicit
ScriptInclude CurrentScriptPath & "foo2.vbs"

call foo2()

If foo2.vbs and foo1.vbs are opened in DIAdem editior you will be able to step into and debug the second script.

 

0 Kudos
Message 2 of 6
(4,824 Views)

Thank you Andreas.

 

I note that in the DIAdem help files it states that ScriptInclude should not be called in loops. Sadly, it does not state why.

 

In my case I am calling the second script in a loop. Should I use ScriptInclude as you recommended or find another way to debug the second script?

 

Regards.

0 Kudos
Message 3 of 6
(4,820 Views)

It is correct, that the ScriptInclude line should not be in a loop. But the foo2 call could be in a loop.

 

Option Explicit
ScriptInclude CurrentScriptPath & "foo2.vbs"

dim i : for i = 1 to 10
call foo2()
Next

 

So if you want to split your scripts into smaller parts to be able to maintain, test them in parts, ScriptInclude is your friend.

IIts like include in other languages. The sccript you include will be inserted at this position.

So its like opening the script in a editor copy it into clipboard and paste it at the position the scriptinclude is done.

 

Thats why it does noot work in loops. So put your code into functions/sub. Include them in global position beneath option explicit.

Use the function/subs at any position in your script.

0 Kudos
Message 4 of 6
(4,810 Views)

OK,

If ScriptInclude cannot be used in a Loop, is there any posibility how to call Scripts in a loop?

I have few scripts which working with one predefined group. I would like to run them for a all groups in a channel. (And I want to call them step by step in a loop with all groupnumbers)

Thanks

Ludek


@AndreasK wrote:

It is correct, that the ScriptInclude line should not be in a loop. But the foo2 call could be in a loop.

 

Option Explicit
ScriptInclude CurrentScriptPath & "foo2.vbs"

dim i : for i = 1 to 10
call foo2()
Next

 

 


 




 

0 Kudos
Message 5 of 6
(2,850 Views)

I you do not need to debug you can use

Call ScriptStart(FileDlgName, [VBSProcName], [AutoObjLetOpen]) 

you want support by the debugger you need to splitup functionality and loop.

 

Functionality foo.vbs

Option Explicit

sub Foo(byref group)
  LogFileWrite "**** " & group.Name
end sub

 and use different scripts by using different scripts

First Group:

Option Explicit
Scriptinclude currentScriptPath & "foo.vbs"

call Foo(data.Root.ChannelGroups(1))

All groups:

Option Explicit
Scriptinclude currentScriptPath & "foo.vbs"

dim grp : for each grp in data.Root.ChannelGroups
  call Foo(grp)
Next
0 Kudos
Message 6 of 6
(2,838 Views)