Community discussions

MikroTik App
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

if statement... how?

Wed Jan 17, 2018 9:42 am

Hi,

How do I do this in a script?

if var x = var y and var z = yes then
else goto another part of the script

Thanks
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2879
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: if statement... how?

Wed Jan 17, 2018 11:19 am

 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: if statement... how?

Wed Jan 17, 2018 12:32 pm

Yes I know to find that info, but as a beginner that is too hard for me to understand..
So I would like to see some examples...
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: if statement... how?

Wed Jan 17, 2018 2:40 pm

:local x [/system identity get name];
:local y "MikroTik";
:local z [/system clock get dst-active];

:if ($x = $y && $z) do={
    :put "Router identify is 'MikroTik' and we are currently in dailight savings time.";
} else={
    :put "Either router identity is not 'MikroTik', we are not currently in dailight savings time, or both.";
};
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2879
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: if statement... how?

Wed Jan 17, 2018 3:44 pm

 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: if statement... how?  [SOLVED]

Mon Jan 22, 2018 9:32 pm

Question answered by a friend who helped me...
 
cicserver
Member
Member
Posts: 303
Joined: Sun Jul 24, 2011 12:04 pm

Re: if statement... how?

Wed Jan 31, 2018 6:32 am

:if (($VAR1 = "YES") && ($VAR2 = "NO")) do={
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: if statement... how?

Wed Jan 31, 2018 9:08 am

:if (($VAR1 = "YES") && ($VAR2 = "NO")) do={
Nope... that's not what I meant... But, see above... SOLVED thanks to a friend...
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26376
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: if statement... how?

Wed Jan 31, 2018 12:50 pm

It would help others, if you could post that solution here.
 
User avatar
LucZWFM
Member Candidate
Member Candidate
Topic Author
Posts: 130
Joined: Tue Dec 26, 2017 10:47 pm
Location: Bergen op Zoom, The Netherlands

Re: if statement... how?

Wed Jan 31, 2018 2:10 pm

It would help others, if you could post that solution here.

Yes, you are right normis...

:if ($var1 = $var2 and $var3 = "<value>") do=
{
<code>
}

Who is online

Users browsing this forum: No registered users and 28 guests