But now there is a problem when there are more queues with the same target address
(but different Packet Marks). When “/ip firewall address-list add” encounters duplicate
address it breaks the script with error “failure: already have such entry” and doesn’t
add the rest of the addresses to the list. How could that be avoided?
Besides, one note if someone else try to use it… for the script you wrote to work in
RouterOS 5.x it needs a small modification in the second line. It should be like this:
:foreach j in=($i->"target-addresses") do={
And in version 5.x it doesn’t compalin about duplicate entries in the address list.
You could either check if there’s one with “find count-only” being different from 0, or you could use “do {} on-error”. I don’t know which is more efficient, but purely on the basis of “cleanness”, I think the “find count-only” way is better.
To minimize the menu changeups, the menu could be moved on top, and “:” being used on the queues, so…
5.x doesn’t support associative arrays, so that won’t work there at all. It only has non-associative arrays, where you needed to know the position of each property value to use it (with :pick), and you hoped MikroTik would not modify it in the next release (which I don’t know if they did, as I’d never used scripts on queues myself back then) OR what most people did is what you did in your first post - use print to find the item’s number, then do a separate “get” for each of its properties. Much less efficient, but far more stable between versions.
Back to this old thread - could you please help me - I have a little bit different task. I am reading simple queue list and put them to file (or log) as mothly stats. But if I have one queue for multiple targets, my script put that line multiple times for each targes. So is there a way to read only the one (first) target from each queue to variable? Thanks