M
M
MrDZ2021-07-05 12:04:12
Mikrotik
MrDZ, 2021-07-05 12:04:12

How to change the value of a variable?

Good afternoon, tell me how to change the value of a variable?

there is an ip for example 192.168.1.1, I want to display the value 192.168.1.100

I make a script
:: local a 192.168.1.1; :local b 99; :local c ($a + $b); :put $c
192.168.1.100

So it turns out, but if you do this:

:local a [ip dhcp-server network get number=[find comment~"defau"] gateway ]; :local b 99; :local c ($a + $b); :put $c
192.168.1.1;99

produces an unexpected response.

If you print

:local a [ip dhcp-server network get number=[find comment~"defau"] gateway ]; :local b 99; :local c ($a + $b); :put [typeof $a]; :put [typeof $b]; :put [typeof $c]

the answer will be:

array
num
array

I don't quite understand how to change the value of the $a variable to num or ip.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2021-07-05
@MrDZ

:pick ... 0

:local a [:pick [ip dhcp-server network get number=[find comment~"defau"] gateway] 0]; :local b 99; :local c ($a + $b); :put $c

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question