This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Copy value to another GA multiple times
#1
Maybe someone can help me.

I have very much groupsadresses
what i want i have adres 63/1/1 till 63/1/28
i will copy the value of 63/1/1 to 63/1/2 and 63/1/2 to 63/1/3 and so go on till 63/1/28
and the same thing for 63/2/1 till 63/2/28

at the moment i did it like
Code:
Elektra_Verbruik_week0maandag = grp.getvalue('63/1/3')
grp.update('63/1/4', Elektra_Verbruik_week0maandag)
Elektra_Verbruik_week0maandag = grp.getvalue('63/1/2')
grp.update('63/1/3', Elektra_Verbruik_week0maandag)
Elektra_Verbruik_week0maandag = grp.getvalue('63/1/1')
grp.update('63/1/2', Elektra_Verbruik_week0maandag)
...........
........

end so on untill 63/1/28
My question is, is there a more easy way to do this?
Reply
#2
This can be done with a loop in a descending order:
Code:
prefix = '63/1/'
for i = 28, 2, -1 do
  value = grp.getvalue(prefix .. (i - 1))
  grp.update(prefix .. i, value)
end
Reply
#3
Thanks Admin, this is working perfect to me
Reply
#4
Maybe someone can help me why this isn't working?

This is working fine
Code:
prefix = '56/0/'
for i = 20, 1, -1 do
  value = grp.getvalue(prefix .. (i - 1))
  grp.checkupdate(prefix .. i, value)
end

Code:
prefix = '56/0/'
for i = 20, 201, -1 do
  value = grp.getvalue(prefix .. (i - 1))
  grp.checkupdate(prefix .. i, value)
end
But this one doesn't, the only thing that was change is the last part of the groupadres, it has a 3 digit.
Is it possible to get this working too?

I have group object from 200 til 220 that i would move, like the first script is doing.
All the group addresses have the same data type too.
Reply
#5
Try changing for i = 20 into 220 as you count down (20 is already lower then 201)
Reply
#6
I see, i thought the 'i = 20' is how many times, but now I see it from group adres 20 til group adres 200, so indeed it can't work.
Thanks Erwin, fijne jaar wisseling.
Reply
#7
It’s start, end, step size and direction (- is countdown)

Fijne jaarwisseling!
Reply
#8
Thanks for explaining
Reply


Forum Jump: