KB-47756: Reading values from a CSV file.

Question:

Can cells from an CSV file be read, and their values used in Elipse SCADA?

Solution:

Yes. There are two possibilities to do so:

  1. Use DDE tags. In this case, the spreadsheet must always be opened.
  2. Use ReadFromFile() function, which allows reading the CSV file as if it were a text file. Then, the script will detect the characters semicolon and line break, separating the values between them. Next, there is a sample script:

dim var, i, size, cc, LSP

// var = read string
// cc = character
// i = FOR counter
// size = read string’s size
// LSP = Last Separator Position

var = ReadFromFile(“File.csv”)
size = Len(var)
LSP = 0

for i=1 to size
   cc = Mid(var, i-1, 1)

   IF cc == “;”
      MessageBox(Mid(var, LSP, i-LSP-1))
      LSP = i
   ENDIF

   IF Asc(cc) == 13
      MessageBox(Mid(var, LSP, i-LSP-1))
      LSP = i+1
   ENDIF

next

NOTE: Attached to this article is a sample application demonstrating the script seen above.

Attachments:

Sample.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *