WinCC Flex - VBscript - loop, arrays and copy

rQx

Lifetime Supporting Member
Join Date
Oct 2010
Location
Trelleborg
Posts
1,051
Hi!

I have no experience at all with VB script but I think I might need something here.

The issue is that we mainly have the WinCC Flexible to LOG values. But since you can't log values that are in an array the tags eat up quickly. So my thought was to make a VBscript that copy the array to seperate internal tags and then I can log the tags as usual.

I have to come up with a solution myself but I only got halfway. From what I read on siemens I shouldn't use arrays from external because it will read the whole array everytime, so in a loop that will take time. So my first script is here:

DIM i, i2, local_array(29)
For i = 0 To 29
local_array(i) = SmartTags("CPU_Array")(i)
Next

I think that this script will loop throu the PLC array and copy it to my internal temporary array in the script right?

In my tag editor I will make tags LOG0, LOG1, LOG2, LOG3, LOG4 etc etc etc and then I want to copy the local_array(0-29) to my seperate LOGs.

For i2 = 0 To 29
SmartTags(LOG & i2) = local_array(i2)
Next

So my problem is: How do I access the seperate internal tags (LOG0 etc) in the smart tag expression? As you see I have made a foolish example to let you know how Im thinking.

/tim
 
Here is an example of how i do it. Stacker_Points is a DB. I think the key is to make sure you use [] for the index.

Code:
SmartTags("Stacker_Points.Stacker_Points[7].X_Axis") = SmartTags("Stacker_Points.Stacker_Points[9].X_Axis")
 
Here is an example of how i do it. Stacker_Points is a DB. I think the key is to make sure you use [] for the index.

Code:
SmartTags("Stacker_Points.Stacker_Points[7].X_Axis") = SmartTags("Stacker_Points.Stacker_Points[9].X_Axis")

Ok, so my code should look like

Code:
For i2 = 0 To 29
SmartTags(LOG[i2]) = local_array(i2)
Next

And this would make me access my individual tags LOG1, LOG2. Just want to clearify that the LOG isn't an array.

Would my whole script then look like:

Code:
DIM i, i2, local_array(29)

For i = 0 To 29
local_array(i) = SmartTags("CPU_Array")(i)
Next

For i2 = 0 To 29
SmartTags(LOG[i2]) = local_array(i2)
Next
 

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,714
What do I need: When They want to do an Import, this is called: DeleteDataRecordMemory hmiFlashMemory, hmiOff, hmiOn...
Replies
2
Views
7,064
Hello fellow PLCTalkers, I am having issues with Tags not updating when used in scripts. Hardware: HMI: MP277 PLC: Siemens CPU 315 WinCC Flex...
Replies
8
Views
16,291
I'm continuing my Siemens education. I need some help with compatibility details. My customer has a machine that was made by a company no longer...
Replies
6
Views
4,023
Hello all. I mainly work with Siemens PLC's and panels for our machines. But now I am faced with a pilot project that has to be as price friendly...
Replies
15
Views
8,036
Back
Top Bottom