04-02-2015 05:08 AM - edited 04-02-2015 05:09 AM
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.
04-08-2015 08:17 AM
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.
04-08-2015 08:56 AM
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.
04-08-2015 10:31 AM - edited 04-08-2015 10:32 AM
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.
06-05-2017 09:47 AM - edited 06-05-2017 09:49 AM
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
06-06-2017 06:22 AM
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