script with "find name"

Hello i am newbie…
I want to create a php script to add credit to my customers.
I think to use: " set [find name=thename] add-credit=thecredit "

But how can i see if thename is wrong and so it has not been found ?

Find returns an array of items. “:len” returns the size of arrays.

[admin@MikroTik] > :if ([:len [/interface ethernet find name=thename]] = 0) do={:put "Not found"} else={:put "Found"}          
Not found

However very often you don’t need to care. Commands that are given an empty item list (like they would be if an item searched for by name doesn’t exist) simply don’t do anything but also don’t error out.

[admin@MikroTik] > /interface ethernet disable [/interface ethernet find name=thename]
[admin@MikroTik] >