I'm essentially trying to create a function which tests the first location I give, in the form:
myComputer.referenceLookup("/address/x/text")
and return the string in that location if it is not NULL or "None" or "" (empty).
If not, I want it to test the next possible location:
myComputer.referenceLookup("/address/1/x/text")
Otherwise, I would like it to return an empty string ("").
I've tried looking in the Lua Manual to no avail as well as testing different forms in repl.it, but unfortunately, I can't replicate a similar example as I usually do when testing.
function firstLine(x)
if myComputer.referenceLookup("/Address/ .. (x) .. /text") != NULL or "None" or "" then
return myComputer.referenceLookup("/Address/ .. (x) .. /text")
elseif myComputer.referenceLookup("/Address/1/ .. (x) .. /text") != NULL or "None" or "" then
return myComputer.referenceLookup("/Address/1/ .. (x) .. /text")
else
return ""
end
end
myComputer.out.firstHouseNumber = firstLine(housenumber)
It's worth noting that the usual way I would reference the fact is as follows:
myComputer.out.firstHouseNumber= myComputer.referenceLookup("/Address/housenumber/text")
or
myComputer.out.firstHouseNumber= myComputer.referenceLookup("/Address/1/housenumber/text")
The platform I'm using doesn't throw errors, it just will return blank instead of running the lua script so I am unable to debug (hence usually using repl.it).
I know this makes it a bit of an abstract question, but if anyone knows how I can do what I am describing, it would be very much appreciated.