rQx
Lifetime Supporting Member
Hi!
So I have a problem with the VB script part of the TIA portal. I'm no good at scripting but I have a script that is working in WinCC Flexible Advance and I wan't to have that one (with some modification) in WinCC TIA. I'm using a comfort panel that is suppose to support VB script. The thing is that when I add a VBscript it automaticly adds a new with name "VBFunction_1". So first of all I can't even edit this name? I added my script and it is showed with no error but when I compile it says ,Compilation failed. Please contact SIEMENS customer support..
I've read some in the manual and it says that I should add parameters to the script but I can't do this either. I can add but I can't change name, it just says "This value is invalid". I've tried to do as the example "meter to inch" in the manual but with nno luck since I can't change names on the script or parameter.
The script I wan't to add is this (if it matters, I guess that my problems begin before this):
Dim fso, f, ts, DataSet
Set fso = CreateObject("Scripting.FileSystemObject")
SmartTags("internalLogName") = "C:\LOG.csv"
DataSet = SmartTags("status_flowBeforeFilterTotalizer") & ";" & SmartTags("status_flowAfterDisc1Totalizer") & ";" & SmartTags("status_flowAfterDisc2Totalizer") & ";" & SmartTags("status_levelBeforeFilterAverage") & ";" & SmartTags("status_levelAfterDisc1Average") & ";" & SmartTags("status_levelAfterDisc2Average") & ";" & SmartTags("status_diffrenceLevelDisc1Average") & ";" & SmartTags("status_diffrenceLevelDisc2Average") & ";" & SmartTags("status_turbidityBeforeFilterAverage") & ";" & SmartTags("status_backwashPressureDisc1Average") & ";" & SmartTags("status_backwashPressureDisc2Average") & ";" & SmartTags("status_drumDisc1SpeedRpmAverage") & ";" & SmartTags("status_drumDisc2SpeedRpmAverage")
If Not fso.FileExists(SmartTags("internalLogName")) Then
fso.CreateTextFile SmartTags("internalLogName")
Set f = fso.GetFile(SmartTags("internalLogName"))
Set ts = f.OpenAsTextStream(8, -2)
ts.WriteLine "Time;Flow before;Flow after disc 1;Flow after disc 2;Level Before;Level after disc1;Level after disc 2;Diffrence level disc 1;Diffrence level disc 2;Turbidity before;BW pressure disc 1;BW pressure disc 2;Drum speed disc 1;Drum speed disc2"
ts.WriteLine DataSet
ts.Close
Else
Set f = fso.GetFile(SmartTags("internalLogName"))
Set ts = f.OpenAsTextStream(8, -2)
ts.WriteLine DataSet
ts.Close
End If
Set ts = Nothing
Set f = Nothing
Set fso = Nothing
So I have a problem with the VB script part of the TIA portal. I'm no good at scripting but I have a script that is working in WinCC Flexible Advance and I wan't to have that one (with some modification) in WinCC TIA. I'm using a comfort panel that is suppose to support VB script. The thing is that when I add a VBscript it automaticly adds a new with name "VBFunction_1". So first of all I can't even edit this name? I added my script and it is showed with no error but when I compile it says ,Compilation failed. Please contact SIEMENS customer support..
I've read some in the manual and it says that I should add parameters to the script but I can't do this either. I can add but I can't change name, it just says "This value is invalid". I've tried to do as the example "meter to inch" in the manual but with nno luck since I can't change names on the script or parameter.
The script I wan't to add is this (if it matters, I guess that my problems begin before this):
Dim fso, f, ts, DataSet
Set fso = CreateObject("Scripting.FileSystemObject")
SmartTags("internalLogName") = "C:\LOG.csv"
DataSet = SmartTags("status_flowBeforeFilterTotalizer") & ";" & SmartTags("status_flowAfterDisc1Totalizer") & ";" & SmartTags("status_flowAfterDisc2Totalizer") & ";" & SmartTags("status_levelBeforeFilterAverage") & ";" & SmartTags("status_levelAfterDisc1Average") & ";" & SmartTags("status_levelAfterDisc2Average") & ";" & SmartTags("status_diffrenceLevelDisc1Average") & ";" & SmartTags("status_diffrenceLevelDisc2Average") & ";" & SmartTags("status_turbidityBeforeFilterAverage") & ";" & SmartTags("status_backwashPressureDisc1Average") & ";" & SmartTags("status_backwashPressureDisc2Average") & ";" & SmartTags("status_drumDisc1SpeedRpmAverage") & ";" & SmartTags("status_drumDisc2SpeedRpmAverage")
If Not fso.FileExists(SmartTags("internalLogName")) Then
fso.CreateTextFile SmartTags("internalLogName")
Set f = fso.GetFile(SmartTags("internalLogName"))
Set ts = f.OpenAsTextStream(8, -2)
ts.WriteLine "Time;Flow before;Flow after disc 1;Flow after disc 2;Level Before;Level after disc1;Level after disc 2;Diffrence level disc 1;Diffrence level disc 2;Turbidity before;BW pressure disc 1;BW pressure disc 2;Drum speed disc 1;Drum speed disc2"
ts.WriteLine DataSet
ts.Close
Else
Set f = fso.GetFile(SmartTags("internalLogName"))
Set ts = f.OpenAsTextStream(8, -2)
ts.WriteLine DataSet
ts.Close
End If
Set ts = Nothing
Set f = Nothing
Set fso = Nothing