[Help] Advanced get & set ..

I want to use get command to set these variables name, target, limit…

for a specific item !
like this set name = xxxx , target=xxxx , max= xxx where item = 3 for example
in order to use these variables in another progress like this example :


: local item [the number of the item ] for example the 7th
: local name [get the name of the 7th item in queue simple]
: local target [get the target-addresses of the 7th item in queue simple]
: local max [get the max limit of the 7th item in queue simple]

then do "use it in any other progress like this for example "
/system backup save name=$name-$target-$max

/queue simple set [/queue simple find name=queue2] name=newname target-addresses=192.168.169.170

Thanks for response , but i mean another thing
I’ll edit the 1st topic for that .

what do you mean by ‘item = 3’? what is ‘item’? I don’t know such object or property…

what do you mean by ‘item = 3’

when you add a simple queue , it gets a number to be ordered .
thanks again

you can’t use item numbers directly in the script.
Use find function
For example you added queue with queue name=myQueue, then

/queue simple set [find name=“myQueue”] limit-at=64000/64000

Ok Mr.mrz
What if I want to do this


: local name [get the name of the queue that applied to the target addresses 192.168.1.15/32]
: local max [get the max-limit of the queue that applied to the target addresses 192.168.1.15/32]


then do "use it in any other progress like this for example "
/system backup save name=$name-$max

so i may replace 192.168.1.15/32 with a variable like ip
then do loop like ip+1 to get them all

{
:local id [/queue simple find target-address=“192.168.1.15/32”];

:local name [/queue simple get $id name];
:local max [/queue simple get $id max-limit];

/system backup save name=“$name-$max”
}

And yes you can do loop, but it doesn’t make sense to save many backup files with identical settings :slight_smile:

Thanks Dear ,
One more thing , how can i loop on your example ??

By the way , i’m not planning to use it for backup ,
I’ll use this for sending these to database with tool fetch

You can’t send data to a server with fetch tool.

Just complete your favor

You can’t send data to a server with fetch tool.

ya , what about this
http://wiki.mikrotik.com/wiki/Netwatch_on_web

Ok you can do it that way :slight_smile:

Loop addresses from 1 to 15

:for i from=1 to=10 do={
  :local id [/queue simple find target-address="192.168.1.$i/32"];

  ...

}

Thanks Mr.mrz

I have a problem now , small one
the names in queues are like this

Sarah Mark

when i use
:local id [/queue simple find target-addresses=“192.168.1.15/32”];
:local name [/queue simple get $id name];
:local max [/queue simple get $id max-limit];

i get these results

name = Sarah
it doesn’t get the whole name !!
and doesn’t get the $max

UP

are you sure?

[admin@MikroTik] /queue simple> { :local name [get "Sarah Mark" name ]; :put $name}
Sarah Mark

ROS v3.22

Yes I’m sure ,
It works in log just fine , but in fetch , doesn’t work , if the name contain spaces
like Sarah Mark
Just send Sarah

you need to parse ‘fetch’ query to replace special characters (like spaces, they are forbidden in URIs) with their ‘%XX’ equivalent