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:
- Use DDE tags. In this case, the spreadsheet must always be opened.
- 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.