On 9/15/2014 6:12 PM, Michail Vidiassov wrote:
Dear Aditya, Peter and All,
I think that what Peter meant was:
the real issue is not teaching me lua and improving the style of my example, but my complaint (correct or not) about inability of lpdf.checkedkey
it looks like your question was not clear then
to correctly fetch false boolean values: they are fetched as nil, just as if they were absent or of incorrect type.
well, they're just not treated special
Please, someone with time and, preferably, authority - take a look at lpdf.checkedkey code (5 minutes maximum). Talking in general about lua, not knowing what lpdf.checkedkey is, does and is supposed to do, does not look like efficient use of time.
you can try this (untested) function lpdf.checkedkey(t,key,variant) local pn = t and t[key] if pn then local tn = type(pn) if tn == variant then if variant == "string" then return pn ~= "" and pn or nil elseif variant == "table" then return next(pn) and pn or nil else return pn end elseif tn == "string" then if variant == "number" then return tonumber(pn) elseif variant == "boolean" then return toboolean(pn) end end end end ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------