I’m “trying” to get a script that gets all the limit-at of the rules that match a parent and that in turn adds all the results in kilobits, so if for example I have 2 daughters with limit-at of 2M/2M I can get a final variable that results in $ example = 4000/4000 but I only get to the point where I get the limit-at I don’t know what else to do, I’ve already read the wiki and I can’t do anything else.
This is the script I have managed to do, but it only does half:
:foreach b in=[/queue simple find parent=parent-example] d={
:global test [/queue simple get $b limit-at];
}
My native language is not English, so understanding the wiki is very difficult for me even with translators, however I understand most of the code I see, please, if you know how to do it, put it as an answer.
Greetings, because I do not think I have explained myself well in the other and in this I also detail that I have not been able to achieve it on my own. It is also written in another way in the hope that google translator does it well
#declare function
global parentTotal do={
#initialize total up and down vars
local totalUp 0
local totalDown 0
#loop over all childs
#print as-value generates an array of associative arrays for each entry
foreach item in=[/queue simple print as-value where parent=$1] do={
#get the limit-at value
local limitat ($item->"limit-at")
#split into up and down values
#up is from start up to /
#down is from /+1 char, to end of string
local up [pick $limitat 0 [find $limitat "/"]]
local down [pick $limitat ([find $limitat "/"]+1) [len $limitat]]
#add it up
set totalUp ($totalUp + $up)
set totalDown ($totalUp + $down)
}
#display and return result in up/down format
put ("$totalUp/$totalDown")
return ("$totalUp/$totalDown")
}
#usage
$parentTotal <parent name>
#declare function
global parentTotal do={
#initialize total up and down vars
local totalUp 0
local totalDown 0
#loop over all childs
#print as-value generates an array of associative arrays for each entry
foreach item in=[/queue simple print as-value where parent=$1] do={
#get the limit-at value
local limitat ($item->"limit-at")
#split into up and down values
#up is from start up to /
#down is from /+1 char, to end of string
local up [pick $limitat 0 [find $limitat "/"]]
local down [pick $limitat ([find $limitat "/"]+1) [len $limitat]]
#add it up
set totalUp ($totalUp + $up)
set totalDown ($totalUp + $down)
}
#display and return result in up/down format
put ("$totalUp/$totalDown")
return ("$totalUp/$totalDown")
}
#usage
$parentTotal <testparentname>