G’day,
I have a situation where I need to run a section of a script to clear out previously configured information on a MikroTik router based on whether a variable is set. Some of the stuff needing clearing is done with a :foreach loop as there may well be multiple instances to wipe out, however it seems that once I enclose this inside a :if loop, the :foreach then becomes invalid and fails to run.
When I run the below code, it executes perfectly:
/interface pppoe-client remove [find]
:foreach item in=[/interface wireless find interface-type="virtual"] do={remove $item}
However, when I try this, the :foreach bombs out:
if ($nukePave = "Yes") do={
/interface pppoe-client remove [find]
:foreach item in=[/interface wireless find interface-type="virtual"] do={remove $item}
}
Does anyone have thoughts on a) whether this is a MikroTik scripting bug/shortcoming, or b) if there’s a better way to achieve what I’m after without needing nesting that’s not working.