WinCE panel doesn't run Runtime VB function
Gentlemen,
I am a new hand try to program Siemens HMI to log data on my own format. I try the following code and find it is just work on PC runtime. In WinCE HMI panel, it doesn't support fso object even it is compiled. The VB script is different between Windows and WinCE. Anyone have a sample code to do the same thing in WINCE HMI?
Dim fso, f, ts, DataSet
Set fso = CreateObject("Scripting.FileSystemObject")
'build the string with filename.
'example: "LOG_2007-10-02.csv"
'you may have to modify the path and filename to your needs.
SmartTags("LOG_WriteFileName") = "\Storage Card USB\Logs"& CStr(DatePart("yyyy",Date)) & "_" & CStr(DatePart("m",Date)) & "_" & CStr(DatePart("d",Date)) & ".csv"
'build the string with the data.
'there is an array tag MXLV with the data.
'the data are REALs as you then have the decimal point in the right place.
'modify MXLV to suit your needs.
DataSet = CStr(Now) & "," & CStr(SmartTags("MXLV")(0)) & "," & CStr(SmartTags("MXLV")(1)) & "," & CStr(SmartTags("MXLV")(2)) & "," & CStr(SmartTags("MXLV")(3))& "," & CStr(SmartTags("MXLV")(4))& "," & CStr(SmartTags("MXLV")(5))& "," & CStr(SmartTags("MXLV")(6))& "," & CStr(SmartTags("MXLV")(7))& "," & CStr(SmartTags("MXLV")(8)) & "," & CStr(SmartTags("MXLV")(9))
'check if the file already exists
'if it does not, create it, write the header line and then the first data line
'if it does, then just write the data line
'update the header line t suit your needs
If Not fso.FileExists(SmartTags("LOG_WriteFileName")) Then
fso.CreateTextFile SmartTags("LOG_WriteFileName")
Set f = fso.GetFile(SmartTags("LOG_WriteFileName"))
Set ts = f.OpenAsTextStream(8, -2)
ts.WriteLine "Timestamp , headertext 1 , headertext 2 , headertext 3 , headertext 4 , headertext 5 , headertext 6 , headertext 7 , headertext 8 , headertext 9 , headertext 10 "
ts.WriteLine DataSet
ts.Close
Else
Set f = fso.GetFile(SmartTags("LOG_WriteFileName"))
Set ts = f.OpenAsTextStream(8, -2)
ts.WriteLine DataSet
ts.Close
End If
'if you need to display the same data from within the HMI, you can write the path+filename to another string.
If SmartTags("LOG_DisplayFileName") = "" Then SmartTags("LOG_DisplayFileName") = SmartTags("LOG_WriteFileName")
Set ts = Nothing
Set f = Nothing
Set fso = Nothing