After /file remove interpretation error ?

Hello!

I would like to ask for some help with my script, as the values on the main line are not reset at the end of the script.
In the last IF branch, after ELSE, it does not jump back to the main branch, but it is paramount that when the /file remove command is run, if commented, it jumps back perfectly.
It is important to delete the file, how could this be resolved to actually delete it, so not just make the text file empty and still jump back to the main branch.

Device: wAP R + R11e-LTE (https://mikrotik.com/product/RBwAPR-2nD)
ROS version: v6.49.11

There’s the code example:

:global dummy;
:local $file "asd.txt";

:set $dummy 1;

:local ping [/ping 8.8.8.8 count=8 size=64 interval=1500ms];
:if ($ping = 0) do={
 :log info ("Do sth if ping was not successful");
} else={
 :log info ("here it is the else branch :D");
 /file remove $file; # If the /file remove is commented we goes back to the main branch.
}

:set $dummy 0; # Nothing happening here if /file remove not commented.

Can you please help me with this?

After /file remove bug?

The first mistake is the usual one:
Assuming that your ignorance does not exist and creating a topic title that refers to a possible bug in RouterOS.

Is wrong to use file as name for variable, no matter explain why for now.

Full of useless “;”
Your script is full of errors, for example never use $ on :global, :local and :set

On the script the file is never created, so why delete them?

Use something that do not do error if the file not exist:
/file remove [find where name=$filename]

And you do not specify where you use the file, neither the polices applied to that script or user that use the scirpt.

Who told I never created for example from Terminal??
It was a dummy script, because I don't want to share my real code.
About the script full of errors, I had 0.01 sec to write this topic :smiley:

Btw, thanks for your reply, it was very useful, but I've figured it.

Well this important advice, gets lost among the unnecessary invectives...