Can someone explain this?

Now to try something I’m not sure will even work (running RouterOS 6.23):

[user@mikrotik] /system script environment> {:local x do={:put "Hi $1"};[$x "Mom"];:set x [:parse ":put \"Hello \$1\""];[$x "Dad"]} 
Hi Mom
Hello Dad
Hi

The “Hi Mom” first output line is exactly what I expected (as documented). Good. Setting the local variable $x to the output of the :parse command in hopes that the resulting code value could be executed with a numbered argument, I wasn’t sure that would work. But it DID work, resulting in “Hello Dad” in output line 2.

Can anyone explain the third line of output? Yeah, that’s the one that’s got me puzzled.

That weird.

You can get rid of it by un[bracket]ing one or both of the called functions:

{:local x do={:put "Hi $1"};$x "Mom";:set x [:parse ":put \"Hello \$1\""];$x "Dad"}

After a bit of testing, looks like the first one you bracket is then re-echoed without the argument, after the next bracketed one.

{
:local x do={:put "Hi $1"}
$x "Mom"
:set x [:parse ":put \"Hello \$1\""]
[$x "Dad"]
:set x [:parse ":put \"Yo \$1\""]
$x "Sista"
:set x [:parse ":put \"Later \$1\""]
[$x "Bro"]
}

output:

Hi Mom
Hello Dad
Yo Sista
Later Bro
Hello

Example 2:

{
:local x do={:put "Hi $1"}
$x "Mom"
:set x [:parse ":put \"Hello \$1\""]
[$x "Dad"]
:set x [:parse ":put \"Yo \$1\""]
[$x "Sista"]
:set x [:parse ":put \"Later \$1\""]
$x "Bro"
}

output:

Hi Mom
Hello Dad
Yo Sista
Hello 
Later Bro

Conclusion: don’t use brackets :smiley: