Subtract from get given IP

Hi, i have this problem:
/global IP [/ip neighbor get number=0 address]; :set “$IP” ($IP-1);
Script Error: cannot substract string from time interval
But it work if i set IP variable manually, there is a way to subtract an ip address given by print or get command?

Thanks

How about this?

:global IP [ :toip ([ :toip [/ip neighbor get number=0 address ] ] - 1)];

Note that using index breaks if no print command was used before. In script you should use something like this if you want to work on the first neighbor:

:global IP [ :toip ([ :toip [/ip neighbor get ([ find where address~"." ]->0) address ] ] - 1)];

Thanks for your answer after many attempt i have found a solution. If you do an addiction to variable +0 is ok, then you can subtract without problems.
Here an example
:set $IP ($IP+0); :set $IP ($IP-1)

The reason why you see this, is that your IP is an string.
Adding 0 to it, it seems that RouterOS convert it to an IP, and you can subtraction.

Correct way to do it, is to convert it to an IP, then do the subtraction.

Cut and past this code and you will see what Is going on. You can try to swap :set $IP [:toip $IP] with :set $IP ($IP+0) and get the correct result, but its done in a wrong way.

{
:local IP "10.10.10.20"
:put $IP
:put [:typeof $IP]
:set $IP [:toip $IP]
:put [:typeof $IP]
:set $IP ($IP-1)
:put $IP
}