Home > Support > Knowledge Base > IVI COM Client Examples > Scripting

Developing a Scripting IVI-COM Client

The IVI-COM drivers produced by VIVID can be accessed from scripting languages like VBScript and JavaScript. A simple example VBScript that can run under the Windows Scripting Host is shown below. To run this script, copy the text into a notepad document and save it with a VBS extension. Windows associates this extension with the Windows Scripting Host. 

Set MyScope = CreateObject("VektrexScope.VektrexScope")

MyScope.Initialize "VektrexScope", True, True, "simulate=true"

Model = MyScope.Identity.InstrumentModel

MsgBox "Instrument Model is " + Model

MyScope.Close

This code is very similar to the examples in the Visual Basic Client example; the one difference is the use of the CreateObject command to create an instance of the driver. The argument passed to Create Object ("VektrexScope.VektrexScope") is in the form appname.objecttype where appname is the name of the application providing the object and objecttype is the type or class of object to create. IVI-COM drivers do not usually expose more than one object, so the repeated name shown above will be common. An interesting option that scripting provides is accessing the driver from a web page by embedding a script in the html as shown below: 

<html>

<p align="center">Instruments Model:

 

<SCRIPT LANGUAGE="VBScript">

 

Set MyScope = CreateObject("VektrexScope.VektrexScope")

MyScope.Initialize "VektrexScope", True, True, "simulate=true"

Model = MyScope.Identity.InstrumentModel

document.write Model

MyScope.Close

 

</Script>

</p>

</html>

 

Copyright 2006, Vektrex, (858) 558-8282,