Unable to strip netmask from Ip address in script

Hi!

I’m using RB5009 and ROS 7.1rc6

Works fine in terminal but won’t work in a script. Can someone help me or is it a bug?

Alt1

:for i from=( [:len $ipaddress] - 1) to=0 do={ 
	:if ( [:pick $ipaddress $i] = "/") do={ 
		:put [:pick $ipaddress 0 $i]
	} 
}

Alt 2

:put [:pick $ipaddress 0 [:find $ipaddress "/"]]

I had to change it to:

:global ipaddress 10.1.101.1/24;
:set ipaddress [:pick $ipaddress 0 [:find $ipaddress "/"]]

to make it work

The solution was to use Global as it was in the Wiki: https://wiki.mikrotik.com/wiki/Manual:Scripting-examples#Strip_netmask

No, that didn’t work for me, I tried the wiki example.
This line is being ignored:

:put [:pick $ipaddress 0 [:find $ipaddress "/"]]

The solution was to set the variable again

:set ipaddress [:pick $ipaddress 0 [:find $ipaddress "/"]]

Is like you do not know scripting,
“:put” simply write on terminal some text,
if you must “put” the result inside a variable, is obvious than you must use set.

And also on CORRECT way (the $ before ipaddress after set command):

:global ipaddress 10.1.101.1/24
:set $ipaddress [:pick $ipaddress 0 [:find $ipaddress "/"]]

Thank you for pointing me in the right direction!
I’m new to this, and old, but still learning!

The forum is here for that,
have a nice day.

Can you help me, what am I doing wrong here?

/tool netwatch set [find comment=“isp4”] src-address=(([/ip dhcp-client get [find interface=“ether1” %ipaddress [:pick $ipaddress 0 [find $ipaddress “/”


I want to get the ip address only from the dhcp client but I can’t do it
thank you very much