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") = "C:\LOGS\LOG_" & CStr(DatePart("yyyy",Date)) & "_" & CStr(DatePart("m",Date)) & "_" & CStr(DatePart("d",Date)) & ".csv"---(LOG_WriteFileName-
IS IT INTARNAL TAG?)
'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))
'
(HOW? I HAVE TAG ARRY BUT THE NORMAL DESCRITE TAGS HOW CAN I EDIT IT HERE)
'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)(
WHAT IS THE PURPOSE OF THIS STATEMENT )
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")
(I NEED TO DISPLY THE REPORT ON ONE SCREEN OF WINCC WHICH I WILL CALL BY ONE BUTTON)
Set ts = Nothing
Set f = Nothing
Set fso = Nothing