02-05-2021 06:22 AM
Hi, I'm using NI DIAdem 2020 SP1. I started to create a script. When I click on the "Run Script" icon at the top of the panel, my script runs fine. But if I double-click the *.VBS file in Windows Explorer, there is a error om Windows Script Host (Variable is undefined: 'Data')
The error is in the line where I wrote Call Data.Root.Clear() in the script. Why?
Best regards
Alwi97
02-05-2021 08:49 AM
Hi alwi97,
All Windows operating systems install a VBScript host (runtime engine) and register that "Windows" VBScript host to be used when a *.VBS file is double-clicked in Windows Explorer. You are getting this error because by double-clicking the *.VBS file you are running that script in the Windows VBScript host, not in DIAdem. The Windows VBScript host only has the variables and commands that appear in "blue" in the DIAdem VBScript editor. Any "red" commands or "green" variables or "brown" objects that you see in the DIAdem VBScript editor are not available in the base Windows VBScript host. The DIAdem VBScript host starts with the standard Windows VBScript host and adds all these DIAdem commands/variables/objects so that you have many more options to program with, but these are only available when you're actually running the VBScript in the DIAdem VBScript host.
Brad Turpin
Principal Technical Support Engineer
National Instruments
02-06-2021 04:15 AM
Hi Brad,
thankyou very much for the explanation 🙂
@Brad_Turpin wrote:
Hi alwi97,
All Windows operating systems install a VBScript host (runtime engine) and register that "Windows" VBScript host to be used when a *.VBS file is double-clicked in Windows Explorer. You are getting this error because by double-clicking the *.VBS file you are running that script in the Windows VBScript host, not in DIAdem. The Windows VBScript host only has the variables and commands that appear in "blue" in the DIAdem VBScript editor. Any "red" commands or "green" variables or "brown" objects that you see in the DIAdem VBScript editor are not available in the base Windows VBScript host. The DIAdem VBScript host starts with the standard Windows VBScript host and adds all these DIAdem commands/variables/objects so that you have many more options to program with, but these are only available when you're actually running the VBScript in the DIAdem VBScript host.
Brad Turpin
Principal Technical Support Engineer
National Instruments
@Brad_Turpin wrote:
Hi alwi97,
All Windows operating systems install a VBScript host (runtime engine) and register that "Windows" VBScript host to be used when a *.VBS file is double-clicked in Windows Explorer. You are getting this error because by double-clicking the *.VBS file you are running that script in the Windows VBScript host, not in DIAdem. The Windows VBScript host only has the variables and commands that appear in "blue" in the DIAdem VBScript editor. Any "red" commands or "green" variables or "brown" objects that you see in the DIAdem VBScript editor are not available in the base Windows VBScript host. The DIAdem VBScript host starts with the standard Windows VBScript host and adds all these DIAdem commands/variables/objects so that you have many more options to program with, but these are only available when you're actually running the VBScript in the DIAdem VBScript host.
Brad Turpin
Principal Technical Support Engineer
National Instruments
Alfredo
02-24-2021 04:37 PM
Hi Gerardo,
The solution is to run VBScripts that make calls into DIAdem functions in a DIAdem VBScript host, that is, from the DIAdem SCRIPT panel. If you try to run a VBScript that relies on DIAdem functions from the bare Windows VBScript host, it knows nothing about them. The "Data" object is custom to DIAdem and gives you the ability to read and write the Group and Channel content of the DIAdem Data Portal, for instance.
Brad Turpin
Principal Technical Support Engineer
NI