Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

DataSocket in VBScript

I'm trying to use DataSocket in a VBScript to periodically post data updates to a DataSocket Server.  I'm getting errors when I try to set some of the public properties of the DataSocket.  The script is as follows:
 
dim oDS
set oDS = CreateObject("CWDSLib.CWDataSocket")
oDS.Url = "dstp://localhost/data"
oDS.AccessMode = Write
oDS.Connect
 
When I try to set the AccessMode property, I get the following error meesage: "Script control error: Value not in enumeration."  If this line is commented out, there are no other errors.  I've also had errors trying to access other attributes such as ConnectionStatus and IsConnected.
 
Does anyone have any suggestions?
0 Kudos
Message 1 of 5
(3,369 Views)

The problem is that VBScript doesn't know what the Write value is. There are two ways that you can handle this. The first way is to define a constant for the value in your script and use your defined constant. The other way is to create a .wsf file and use the reference element to reference the type library so that the script recognizes the value. For example:

<job id="DataSocketExample">
    <reference object="CWDSLib.CWDataSocket" />
     
    <script language="vbscript">
    Dim ds
    Set ds = CreateObject("CWDSLib.CWDataSocket")
    ' Note that the value is cwdsWrite, not Write
    ds.AccessMode = cwdsWrite
    MsgBox ds.AccessMode
    </script>
</job>

- Elton

0 Kudos
Message 2 of 5
(3,356 Views)
Thanks, Elton.  I decided to go with declaring a constant in my situation.  From information that I found in the Knowlegde Base, I've concluded that the values to use to set the AccessMode property are as follows:
 
2 = Read
3 = ReadAutoUpdate
4 = Write
5 = WriteAutoUpdate
 
Is this correct?
 
 
0 Kudos
Message 3 of 5
(3,348 Views)

Yes.

- Elton

0 Kudos
Message 4 of 5
(3,340 Views)

I'm having trouble posting data from my script to the DataSocket Server.  I used an example project from the web site that contained a DataSocket reader and writer to do a quick test of the DataSocket Server, and it works O.K.  However, when I try run my script, I don't see data updates on the reader(which is set up in the ReadAutoUpdate mode).

The script is called by a third party application to post a data update, and it runs rather infrequently (maybe every 10 to 15 minutes).  The script basically reads a block of data (ot type double) from the application's database into an array, and attempts to post this array to the DataSocket server.  The attached code segment shows the key parts of the script.  Am I setting up the DataSocket Write operation correctly?

0 Kudos
Message 5 of 5
(3,326 Views)