recognize missing argument

Moderator: leecollings

Post Reply
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

recognize missing argument

Post by manjh »

I have a function that is called from several places in LUA scripts, and I want to add a parameter to it.
In stead of going through all scripts and modify the call, I would like to handle this in the function, and assign a default value if the parameter is missing.
How can I check this? In other words, how can I test for a nil value?
Hans
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: recognize missing argument

Post by manjh »

Never mind, I already had it but missed a small typo in my code.... :mrgreen:

Simply compare the input parameter to nil and "" does the trick: if it is missing or empty I can assign the default.
Hans
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest