05-06-2008 05:19 PM
05-07-2008 02:32 PM
Hi Jim,
It's good to hear from you. Unfortunately, there's no way to kill a running script in VBS through the ActiveX server, because DIAdem has a script stack. The VI can choose to run the script asynchronously as far as LabVIEW is concerned, but there is only one synchronous script stack in DIAdem, so a second ActiveX command has to wait until the first one has completed before DIAdem will run it.
You need to add polling to the VBScript, and you need to poll semthing that the DIAdem script can read from and which LabVIEW can write to without using the ToCommand ActiveX server. A registry key or environment variable or just a plain old ASCII file would all fit the bill.
Here's the VI I used to test that my understanding of the script stack is correct-- note that this VI does NOT succeed in killing the running VBScript.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-07-2008 04:06 PM
Hello Brad!
I don't like to correct you but I have to ![]()
While a script is running it is possible to use the ToCommand interface. There are no restrictions in setting variables. Assuming you have a script running in DIAdem like this:
Option Explicit
B1 = false
Do While not B1
Pause 0.5
Loop
MsgBox "Finished"
You can change the B1 value via OLE. I can't test it with LabVIEW but you can use this script in Windows (outside of DIAdem) to test:
Option Explicit
Dim oDIAdem
Set oDIAdem = CreateObject("DIAdem.ToCommand")
Call oDIAdem.BoolVarSet("B1", true)
Or is there a limitation in the VI?
Matthias
| Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |
05-08-2008 12:07 PM
Hi Matthias,
Well, that's exactly what I thought I had tried in the example I posted that I said did not work, except that I used T1 istead of B1. But now that I look at your code closer, and try it out in a Windows VBScript on my machine, I now see my mistake. The "___VarSet()" methods do indeed run asynchronously even while DIAdem is running a VBScript. In the VI I posted yesterday, I had used "CmdExecuteAsync()" instead of "TextVarSet()" or "BoolVarSet()" to test my understanding of DIAdem's script stack.
It turns out you are completely correct. The "___VarSet()" methods work just fine. I still believe that the "CmdExecute___()" methods load up the DIAdem script stack and that the script stack executes sequentially, but the "BoolVarSet()" method you suggested is the ideal way to accomplish Jim's request, even if it does require polling within the running VBScript. If it turns out that the DIAdem script stack does not execute sequentially, regardless of whether you use the "CmdExecuteSynch()" or "CmdExecuteAsync()" methods, please let me know. My understanding is that the "Sync" or "Async" methods merely designate whether the command returns immediately in the calling language (C, LabVIEW, etc.), but has NO BEARING on how the commands are executed in DIAdem-- I believe these comands are always executed synchronously in DIAdem. This is what I refer to as the DIAdem script stack, the list of all commands waiting to execute sequentially which have been requested through ToCommand.
I rebuilt the VI using Matthias' approach, and now it works in both DIAdem 10.2 and 11.0 Beta2.
Thanks Matthias,
Brad Turpin
DIAdem Product Support Engineer
National Instruments