Discovered today that if you send a function an argument, you can no longer use a global variable within the function. Once a argument is passed to the variable, the global variable is no longer referenced by the root, but only by the arguments that are passed in.
Example:
:global "physInterface" ether6;
:global "AddSingleVlan" do={
/interface vlan add interface=$physInterface name=$1 vlan-id=$2;
:put "VLAN $2 has been added";
$AddSingleVlan $newvlanname $newvlanid
Does not work. RouterOS will kick back an error stating that interface was not set/defined.
However this does…work.
:global "physInterface" ether6;
:global "AddSingleVlan" do={
/interface vlan add interface=$1 name=$2 vlan-id=$3;
:put "VLAN $2 has been added";
}
$AddSingleVlan $physInterface $newvlanname $newvlanid