Kuinka voimme auttaa sinua tänään?

Example of VBScript that reads CSV files

DISCLAIMER

The example below is intended to demonstrate one or more features or methods and is presented as a configuration example only. Schneider Electric assumes no liability for the use or application of this example or any portion thereof.

Sometimes it is necessary to read a text file (.CSV in this case) in ClearSCADA. If the read is triggered by an operation action (clicking a button), a script can be used.
The example below shows one way to read a CSV file using VBScript. It reads only one line, but can be easily modified to read multiple lines:

sub Read1()
' Create object that will be used to read a file
Set fso = CreateObject("Scripting.FileSystemObject")
' Open the file for reading text; first parameter is the full file name with path
' The machine running the script must have access to the file

Set file = fso.OpenTextFile ("z:\zCSVtest.csv", 1)

' Read first (and only) line
line = file.Readline

' split the line in array entries; the values are separated by comma
arrValues = Split(line, ",")

' Assuming we are reading 3 values, double floats, store each element of the array in the proper point
Server.SetOPCValue ".A1", CDbl(arrValues(0))
Server.SetOPCValue ".A2", CDbl(arrValues(1))
Server.SetOPCValue ".A3", CDbl(arrValues(2))

' Close file
file.Close

msgBox "Done"

end sub


Schneider Electric Suomi

Tarvitsetko apua?

Tarvitsetko apua?

Tuotevalitsin

Tuotevalitsin

Valitse tarpeitasi vastaavat tuotteet ja lisävarusteet nopeasti ja helposti.

Pyydä tarjous

Pyydä tarjous

Ota yhteyttä myyntilomakkeen kautta. Asiantuntijamme ovat sinuun yhteydessä.

Löydä lähin jälleenmyyjä

Löydä lähin jälleenmyyjä

Löydä helposti lähin jälleenmyyjä.

Asiakaspalvelukeskus

Asiakaspalvelukeskus

Löydä tukiresurssit kaikkiin tarpeisiisi yhdestä paikasta.

  • Tuotedokumentaatio
  • Ohjelmistolataukset
  • Tuotevalitsin
  • Tuotteen korvaaminen ja vaihtaminen
  • Asiakaspalvelukeskus
  • Etsi toimistomme
  • Pyydä tarjous
  • Osta täältä
  • Shop.se.com/fi/fi sulkeutuu
  • Schneider Electricin yhteisö
  • Uramahdollisuudet
  • Yritys
  • Ilmoita väärinkäytöksestä
  • Saavutettavuus
  • Newsroom
  • Sijoittajat
  • Tutustu EcoStruxure
  • Toimipisteet Suomessa
  • Löydä jälleenmyyjä
  • Avoimet työpaikat
  • Blogi
  • Tietosuojakäytäntö
  • Evästeilmoitus
  • Käyttöehdot
  • Muokkaa evästeasetuksia