WinCC TIA - VB script

rQx

Lifetime Supporting Member
Join Date
Oct 2010
Location
Trelleborg
Posts
1,051
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
 
I cant access TIA at the moment so i cant try your script but one thing i notice right away is that you are using Scripting.FileSystemObject which is wrong and you must adjust the paths to match a panel you cant use "C:\LOG.csv"


Use FileCtl.FileSystem for WinCE panels. Here is one example but there are plenty if you Google it.



Properties is where you adjust names and add parameters

wincc_v11_skripte_tipps_und_tricks_02_e.png
 
Last edited:
Thanks , I guessed I had to change it.
But I cant make changes to the script name or rename parameters. It just gives me error
 
Here is where my initial problems is.
1. Can't change name of script - all scripts
2. Can't add parameters - all scripts
3. Compile doesn't work - only on the script I posted

Problem.jpg
 
Side note: I've tried to understand and learn VBscript but where do I find it best to aid me when developing for CE? For instance, how do I know that fileCtl is used on CE and not PC? Is there a list of available instructions for CE respective PC?
 
Have you removed the faulty script from the catalog before you try to add parameters and change name on the other scripts. From your screenshot it looks like that's your problem.



How do I know that fileCtl is used on CE and not PC? Is there a list of available instructions for CE respective PC?


Yes there is a list available i have a copy somewhere i will send it once i find it.


It is the underlying operating system that handles things differently. I don't know why Microsoft choose to have different syntax for CE and regular Windows. Probably there where different teams that develop the different script engines and they did not talk to each other. You just have to learn this i guess.
 
Yes, I have even tried to make a new project with only a comfort panel and then add a script and try to rename it. Same thing! Frustrating to say the least
 

Similar Topics

Hey guys. I am tyring connect from my HMI (TP1200) to a network location and open a file from a folder. The twist is I don't know what the file...
Replies
1
Views
4,738
In our production plant we have multiple different networks (subnets). IT dept have setup routing between them so different subnets can...
Replies
0
Views
109
I created a project with Tia portal wincc runtime advanced PC station and also activated its smartserver for some smartclients to connect to it...
Replies
1
Views
332
Hello, just started my first project with a unified HMI. I want to use an image as background, how is this accomplished?
Replies
1
Views
553
Hi all, I really need help with this one. I'm at a complete loss... For months and months, I've had no problems with pressing a NEXT button to...
Replies
14
Views
1,450
Back
Top Bottom