DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Viewing script errors when script is called via LabVIEW

I start a script in DIAdem via LabVIEW. If an error occurs in the script, the message window is not visible until DIAdem is brought to the front. So the user is left to wonder why the LabVIEW program is not responding. Is there a way to pass the error back to LabVIEW instead of displaying it in a message window in DIAdem? BTW, I have a modal VI running that calls the script. I suppose that may be why the message window is hidden, but it still would be nice to get the error back to LabVIEW so I can halt the VI automatically.
 
George
0 Kudos
Message 1 of 7
(3,987 Views)
Hi George,
 
I think you should try using DIAdem's internal error checking routines-- these are global in scope and persistent even after a VBScript ends or errors.  The below code can be called from your LabVIEW VI before and after the VBScript you want to run.  I haven't checked this with an actual VBScript in the middle, but it would occur where the "L1:= ProgramRevision(1,3,4)" command happens in the below VBScript:
 
Set ToCommand = CreateObject("DIAdem.ToCommand")
Call ToCommand.CmdExecuteSync("LastErrorReset")
Call ToCommand.CmdExecuteSync("AutoIgnoreError:= 1")
Call ToCommand.CmdExecuteSync("L1:= 0")
Call ToCommand.CmdExecuteSync("L1:= ProgramRevision(1,3,4)")
'Call ToCommand.CmdExecuteSync("L1:= ProgramRevision")
'Call ToCommand.CmdExecuteSync("LastErrorReset")
Call ToCommand.CmdExecuteSync("LastErrorGet")
Call ToCommand.IntegerVarGet("L1", Version)
Call ToCommand.IntegerVarGet("LastErrorNo", ErrNum)
Call ToCommand.TextVarGet("LastErrorFile", ErrText)
Call ToCommand.IntegerVarGet("LastErrorPart", ErrPart)
Call ToCommand.CmdExecuteSync("AutoIgnoreError:= 0")
Set ToCommand = Nothing
MsgBox "DIAdem Revision = " & Version & vbCRLF & "ErrNo = " & ErrNum & vbCRLF & "ErrMsg = " & ErrText & vbCRLF & "ErrPar = " & ErrPart
 
The VBScript above should be run out of Windows Explorer by double-clicking on it.
 
Let me know if you have additional questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 2 of 7
(3,958 Views)

Brad,

If I'm reading the script you mentioned correctly it looks like it will also display a message box from DIAdem. That's part of the problem I'm having with my script. DIAdem is minimized while running my script and when the error message box happens it's also minimized so there's no indication to the user of a problem. Maybe I misunderstood what the script you sent does.

Also you mentioned at the end that the VBScript above should be run out of Windows Explorer by double-clicking on it. But earlier you said it should be run from LabVIEW. I'm confused.

George

0 Kudos
Message 3 of 7
(3,957 Views)

Hi George,

what Brad means is that this script works outside of DIAdem. So You can operate it also from LabVIEW.

The script is just an example how to use the DIAdem automation interface to suppress error messages, get the error message and display it seperately.

In order to supress error messages in DIAdem the script sets the DIAdem variable AutoIgnoreError=1. In order to reactivate the display of error messages in DIAdem AutoIgnoreError must be set back to 0.

Hope this helps,

Thomas

Message Edited by ThomAC on 02-25-2006 12:34 AM

0 Kudos
Message 4 of 7
(3,876 Views)
Thanks for the update, but I guess I'm a little dense and still confused. How do I call it from LabVIEW? Do I save the text to a file with a VBS extension and then use the LV-DIAdem interface VIs to call the script? Assuming I run that script, if an error does occur in another DIAdem script how does that message manifest itself - through a Windows popup message?
 
George
0 Kudos
Message 5 of 7
(3,860 Views)
George,

I created some VIs to perform the same functionality as Brad has shown.  Setting AutoIgnoreError to 1 tells DIAdem to ignore run time errors.  This means that a popup will not show in the background.  However, you will have to poll for errors after performing commands to see if a run-time error occured and what error actually occured.  The "LastErrorGet" call fills the "LastErrorNo", "LastErrorFile", and "LastErrorPart" with any error that occured during the execution of script commands.  You will have to poll for each case where you want to check for an error.  There is an example VI included that shows how to use the VIs.  Use the "Hide DIAdem Error Popups" to tell DIAdem to ignore run-time errors.  Then reset the error status with "Clear DIAdem Errors" before the execution of a command.  You can then use "Get DIAdem Errors" to poll for any errors that occured after the command has been executed.  Before you close the DIAdem application reference call "Show DIAdem Error Popups" to reset DIAdem so that Error Popups will be shown once again.

Please let me know if you have any questions on using the VIs or using the DIAdem error variables.

Thanks,

Tyler Tigue
Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(3,850 Views)
Thanks for all the examples. I'll have a look at it this week.
0 Kudos
Message 7 of 7
(3,840 Views)