Static route for dinamic ip address

somebody can help to make script for my case,
I am really newbie in this scripting case,

I have one router with 2 gateway,
1 already fine becouse just put the default route like ussuall,

but I have aproblem with the 2nd gateway, becouse using dinamic ip address and dinamic gateway also
I am use it only for spesific network destenation,
basicly the gateway is always the same like the network address of “/ip address print”

is it possible to make script
/ip router (on interface x) gateway=(network address(on ip address on interface x))

this is a scripter newbie
please help,
help please… :laughing:

for example address vlan1

{
# get ip address
:local myIP [/ip address get [/ip address find interface="vlan1"] address ];

# get rid of netmask
:for i from=( [:len $myIP] - 1) to=0 do={ 
	:if ( [:pick $myIP $i] = "/") do={ 
		:set myIP [:pick $myIP 0 $i] ;
	} 
}

:put $myIP;
# now you can set gateway

/ip route add gateway=$myIP

}

But if you have two gateways, you also have to use poicy routing:
http://www.mikrotik.com/testdocs/ros/2.9/ip/route.php?permalink=0.40614793467819404