Community discussions

MikroTik App
 
sergeda
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 78
Joined: Wed Sep 20, 2006 6:03 am

Command to interrupt script execution in :if?

Tue Jun 10, 2008 8:48 am

Hi all.
I'm trying to make simple check at start of my script and if check fail just interrupt script execution. I can't find a command to do this in manual. Exit, quit or something else? Can somebody help me with this?
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7198
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Command to interrupt script execution in :if?

Tue Jun 10, 2008 11:26 am

:if ( condition = true ) do={ 
   < your code >
}
Thats it if check fail your code will not be executed
 
sergeda
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 78
Joined: Wed Sep 20, 2006 6:03 am

Re: Command to interrupt script execution in :if?

Tue Jun 10, 2008 11:56 am

Thank you mrz
But what I actually want to achieve is to make something like:
:if ( condition = true ) do={
< command wich brakes execution of script >
}

I just don't want to use multiple nested if but if it is the only way, I'll try.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7198
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Command to interrupt script execution in :if?

Tue Jun 10, 2008 12:05 pm

as far as I know unfortunately nested ifs are the only way. There are no stop script command.

but there could be a workaround:

:if ( condition=true ) do={
/system script job remove [/system script job find script=<script_name>;
}
not sure if it will work but you can try.