Community discussions

 
User avatar
CZFan
Forum Guru
Forum Guru
Topic Author
Posts: 1358
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Randburg
Contact:

How to check if array is empty

Sat Jul 20, 2019 3:00 pm

Hi,

How can I check if an array is empty, e.g. I would like to:

If array is empty, do "Log Message 1"
else
do "Log Message 2"
MTCNA, MTCTCE, MTCRE & MTCINE
 
Chupakabra303
just joined
Posts: 12
Joined: Tue Jun 20, 2017 3:07 pm

Re: How to check if array is empty

Sat Jul 20, 2019 5:14 pm

:if ([:len $array1] > 0) do={
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1290
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: How to check if array is empty  [SOLVED]

Sat Jul 20, 2019 7:49 pm

Complete it would be:
:if ([:len $array1] > 0) do={
	:log info message="2"
} else={
	:log info message="1"}
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
CZFan
Forum Guru
Forum Guru
Topic Author
Posts: 1358
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Randburg
Contact:

Re: How to check if array is empty

Sat Jul 20, 2019 11:56 pm

Thx to both, selected Jotne's post as solution due to it being more "complete"
MTCNA, MTCTCE, MTCRE & MTCINE

Who is online

Users browsing this forum: No registered users and 4 guests