Community discussions

MikroTik App
 
User avatar
CZFan
Forum Guru
Forum Guru
Topic Author
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
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"
 
Chupakabra303
just joined
Posts: 14
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: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

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"}
 
User avatar
CZFan
Forum Guru
Forum Guru
Topic Author
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
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"

Who is online

Users browsing this forum: Gadulowaty and 54 guests