VBS problem, arrayproblem in VB-Script... WinCC Flex

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Dim i, a(10)

For i = 0 To 9 Step 1
a(i) = SmartTags("visuf")(i)
Next

For i = 10 To 2 Step -1
a(i)= a(i-1)
a(0)= SmartTags("valuetag")
Next

For i = 0 To 9 Step 1
SmartTags("visuf")(i) = a(i)
Next


This code doesn't work, only tag visuf[0] changes...
What could be the problem. I can compile it, shifting just doesn't work...
What I want is Fifo
 
For i = 10 To 2 Step -1
a(i)= a(i-1)
a(0)= SmartTags("valuetag")
Next


Should this be For i = 10 to 1 Step -1

For i = 10 To 1 Step -1
a(i)= a(i-1)
Next
a(0)= SmartTags("valuetag")
 
Last edited:
Hi

Thanks for your help...
But, now my index 1 also changes.

fifo.JPG

current code:

Code:
Dim i, a(10)

For i = 0 To 9 Step 1
a(i) = SmartTags("visuf")(i)
Next

For i = 10 To 1 Step -1
    a(i)= a(i-1)
    a(0)= SmartTags("valuetag")
Next

For i = 0 To 9 Step 1
SmartTags("visuf")(i) = a(i)
Next
For i = 10 To 2 Step -1
a(i)= a(i-1)
a(0)= SmartTags("valuetag")
Next


Should this be For i = 10 to 1 Step -1

For i = 10 To 1 Step -1
a(i)= a(i-1)
Next
a(0)= SmartTags("valuetag")
 
I am not following you.
After the looping, you get this. For i = 10 To 1 Step -1

A10 = A9
A9 = A8
A8 = A7
A7 = A6
A5 = A4
A4 = A3
A3 = A2
A2 = A1
A1 = A0

You then move your incoming new value into A(0).
 
Fifo

This is Fifo, but when I run the script, index 0 and 1 are becomming the same new value...

I am not following you.
After the looping, you get this. For i = 10 To 1 Step -1

A10 = A9
A9 = A8
A8 = A7
A7 = A6
A5 = A4
A4 = A3
A3 = A2
A2 = A1
A1 = A0

You then move your incoming new value into A(0).
 
I wrote a small program in Visual Basic and used your code with the modifications I mentioned. Everything shifted correctly.

After the looping, your new value comes from "valuetag".
a(0)= SmartTags("valuetag")

The very last loop statement would have took the old A(0) and moved it into A(1). When i is equal to 1.
a(i)= a(i-1) = a(1)= a(1-1)
 
Found it

Dim i, a(10)

For i = 0 To 9 Step 1
a(i) = SmartTags("visuf")(i)
Next

For i = 10 To 1 Step -1
a(i)= a(i-1)
a(0)= SmartTags("valuetag")
Next

For i = 0 To 9 Step 1
SmartTags("visuf")(i) = a(i)
Next


has to be:


Dim i, a(10)

For i = 0 To 9 Step 1
a(i) = SmartTags("visuf")(i)
Next

For i = 10 To 1 Step -1
a(i)= a(i-1)
Next
a(0)= SmartTags("valuetag")

For i = 0 To 9 Step 1
SmartTags("visuf")(i) = a(i)
Next


It may not be written in the for next loop.
 

Similar Topics

I wrote: Historian 'Schrijf vorige batch weg naar de csv historian 'Wegschrijven van de vorige omdat eventueel gewijzigde parameters...
Replies
0
Views
1,646
Hello, I just started learning WinCC V8.0 3 days ago, so I'm still new to how everything works in this program. I've created a pop-up with a...
Replies
2
Views
684
Hello. I am trying to do some basic file operations (move file from one folder to another, rename file in the new folder etc) and usually I just...
Replies
1
Views
2,189
Hello everyone. I'm trying to export data to excel from Wincc. My code is global action that executed every second that create excel filer per...
Replies
1
Views
5,735
Hi all. I am trying to write vbs code to copy data SQL from one server to another . i can write data to blockdata, but i cannot copy data from...
Replies
0
Views
1,668
Back
Top Bottom