Write Tag Array
Home Product
Details Free 
Demo Pricing &
Ordering Related
Products Support About Us

Please use our Code Center to obtain source-code and example projects/solutions:

http://codecenter.softwaretoolbox.com

 

Writing to Array Tags using the OPC Web Client ActiveX Controls

The following example shows you how you can create a scripted-application that runs from within Internet Explorer itself.
This example uses the following development languages: vbscript and javascript

Objective

    The web-page will have a button only. 10 values will be written to the Array-Tag upon clicking the button. A message will be displayed indicating the success/failure of the write transaction.

    This example assumes that you have the Software Toolbox TOPServer installed along with a customized "simdemo.opf" project that contains Tags of type Array. You can download our test project here..

Source code

    In order for our web-page to do anything, we now need to add some scripting that will:

    • respond to the button being clicked
    • perform the tag read request
    • display the value in the textbox

    VBSCRIPT

<html>

<head>
<title>OPC Web Client, writing to an Array-Tag</title>
</head>

<body>
<input type="button" name="b1" value="Write Array">
</body>

<script language="vbscript">
sub b1_onClick
  On Error Resume Next
  '
  'create an array object and assign some values to it

  dim objArray(9)
  For i=0 To 9
   objArray(i) = i
  Next
  '
  'now connect to the opc server and write the value

  set opcWebClient = CreateObject("OPCLabs.EasyDA3.0")
  opcWebClient.WriteItemValue "", "SWToolbox.TOPServer", "Channel_1.Device_1.TagArray_1", objArray
  '
  'now check if an error occurred or not

  If Err.Number = 0 Then
   Msgbox "Ok, successfully wrote to Array Tag"
  Else
   Msgbox "Error: " & Err.Number & ", " & Err.Description
  End If
end sub
</script>
</html>

    Simply place the above text under the "</body>" HTML tag and then save your HTML page. Now open that web-page directly from Internet Explorer and then click on the button.

    JAVASCRIPT

Feature not currently supported within Javascript due to the differences in Array handling for this development language. This feature will be made available in the next product release.

    Sign-up to our newsletter to receive product updates & other important information.

Copyright Software Toolbox, Inc., 1996-2004, All Rights Reserved Worldwide.
148A East Charles Street, Matthews, North Carolina, USA 28105
Phone: 704-849-2773 or 1-888-665-3678 (US), Fax: 704-849-6388
sales@softwaretoolbox.com | support@softwaretoolbox.com