Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 19714

Scripting • Re: Problem with :pick

$
0
0
Hi,

Thank you for your answers
Code:
:global ipaddress [/queue simple get 1 target];:global test [:global ipaddress; :find $ipaddress "/"];
Inside the function, ipaddress is not known so you have refer to it by :global ipaddress.
With this solution, I have a result : "$ipaddress"
Couple other things too:
- The first line use "get 1", however that's not an *id so it depends on print being called to establish the index of 1. Using "get ([find]->0)" or "get [find name=queue1]" instead avoid needing.
- There can be multiple "target" from "/queue simple get", and :find does not work with arrays & so need use get the 1st element listed as "target" first

For example,
Code:
:global ipaddresses [/queue simple get [find name=queue1] target]:global ipaddress [:pick $ipaddresses 0 ] :global cidrmark [:find  $ipaddress "/"]:put "$[:pick $ipaddress 0 $cidrmark]"

Although these could be a locals and combined:
Code:
{:local ipaddress ([/queue simple get [find name=queue1] target]->0); :put "$[:pick $ipaddress 0 [:find  $ipaddress /]]"}

- The first line use "get 1", however that's not an *id so it depends on print being called to establish the index of 1. Using "get ([find]->0)" or "get [find name=queue1]" instead avoid needing.

It was for the example, I understood that the get 1 corresponded to the number present in this menu on Winbox

- There can be multiple "target" from "/queue simple get", and :find does not work with arrays & so need use get the 1st element listed as "target" first

Indeed, you have found my problem, I had not seen this return as an array but a character string !

thanks a lot for your help

Good evening to you

Xavier

Statistics: Posted by xaviernuma — Mon Apr 01, 2024 9:53 pm



Viewing all articles
Browse latest Browse all 19714

Trending Articles