for i from=1 to=3 do={
:local x;
:set x (“type” . $i)
:put $x
/ip firewall mangle
add action=mark-connection chain=prerouting protocol=tcp dst-port=80 new-connection-mark=$x
}}
In this case,the “new-connection-mark” in the mangle is “type1”,“type2” and “type3”,but I really want is “http” and “webbank”,“game”,I want the value of variable “type*” rather than variable itself. How to do?
The variable has to be global, but the pointer can be local.
You can also assign value to the variable pointed by $pointer, but you have to store it first in a global variable:
… and there is a straightforward method too.
See commands available at /system script environment.
# pointer: a string containing the name of a global variable
:local ptr "x'
# function to read the pointed value
:global rd do={:return [/system script environment get $1 value]}
# function to set the pointed value (does not create a variable)
:global wr do={ [/system script environment set $1 value=$2]}
# create the variable
:global x
# set its value
$wr $ptr 10
# read and write out
:put [$rd $ptr]