I have this script:
Historian is this script:
The problem is...
The second script is called in the first script at Line 1,
I want to log my tags with historian, after that the rest of the code may send the data of the chosen record to the plc and delete the one on the panel.
Problem is, I get the values in historian that have been set by the rest of the code...
this means that historian script is not executed first ???
Why not, I setted it on Line 1 before my other code...
Code:
Historian
SetDataRecordToPLC "Batches", SmartTags("Record"), hmiOn, Null
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
DeleteDataRecord "Batches", SmartTags("Record"), hmiOn, hmiOn, Null
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Historian is this script:
Code:
Dim fso, f, ts, DataSet, Path, Dataformat
On Error Resume Next
Path = "C:\"
Set fso = CreateObject("Scripting.FileSystemObject")
SmartTags("File") = Path & SmartTags("BATCHES.Info._klantnr") & ".csv"
Dataformat = "Datum" & ";" & "Tijd" & ";" & "Klantnaam" & ";" & "Klantnummer" & ";" & "Ordernummer" & ";" & "Regelnummer" & ";" & "Artikelnummer" & ";" & "Leverdatum" & ";" & "Matrijs Hoek 1" & ";" & "Matrijs Hoek 2" & ";" & "Buistype" & ";" & "Buislengte" & ";" & "Buisdiameter" & ";" & "Buismateriaal" & ";" & "Wenslengte" & ";" & "Wenshoek 1" & ";" & "Wenshoek 2" & ";" & "Wensaantal" & ";"
DataSet = (Date & ";" & Time & ";" & SmartTags("BATCHES.Info._klantnaam") & ";" & SmartTags("BATCHES.Info._klantnr") & ";" & SmartTags("BATCHES.Info._ordernr") & ";" & SmartTags("BATCHES.Info._regelnr") & ";" & SmartTags("BATCHES.Info._artikelnr") & ";" & SmartTags("BATCHES.Info._leverdatum") & ";" & SmartTags("BATCHES.Info._matrijs_hoek_1") & ";" & SmartTags("BATCHES.Info._matrijs_hoek_2") & ";" & SmartTags("BATCHES.Buis._type") & ";" & SmartTags("BATCHES.Buis._lengte") & ";" & SmartTags("BATCHES.Buis._diameter") & ";" & SmartTags("BATCHES.Buis._materiaal") & ";" & SmartTags("BATCHES.Wens._lengte") & ";" & SmartTags("BATCHES.Wens._hoek_1") & ";" & SmartTags("BATCHES.Wens._hoek_2") & ";" & SmartTags("BATCHES.Wens._aantal"))
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
If Not fso.FileExists(SmartTags("File")) Then
fso.CreateTextFile SmartTags("File")
Set f = fso.GetFile(SmartTags("File"))
Set ts = f.OpenAsTextStream(8,-2)
ts.WriteLine Dataformat
ts.WriteLine ""
ts.WriteLine DataSet
ts.Close
Else
Set f = fso.GetFile(SmartTags("File"))
Set ts = f.OpenAsTextStream(8,-2)
ts.WriteLine DataSet
ts.Close
End If
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set ts = Nothing
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Storage of the data was successful!"
The problem is...
The second script is called in the first script at Line 1,
I want to log my tags with historian, after that the rest of the code may send the data of the chosen record to the plc and delete the one on the panel.
Problem is, I get the values in historian that have been set by the rest of the code...
this means that historian script is not executed first ???
Why not, I setted it on Line 1 before my other code...