On Sun, Nov 14, 2010 at 06:55:20PM +0100, Hans van der Meer wrote:
In transforming dates through a Lua-call I get a nil error I do not understand.
The luatex code = \startluacode hvdm = hvdm or {} require "lpeg" -- Transform date in Lua from yyyymmdd to dd-mm-yyyy with checks hvdm.day = lpeg.R("02") * lpeg.R("09") + lpeg.P("30") + lpeg.P("31") - lpeg.P("00") hvdm.month = lpeg.P("0") * lpeg.R("19") + lpeg.P("10") + lpeg.P("11") + lpeg.P("12") hvdm.year = lpeg.R("12") * lpeg.R("09") * lpeg.R("09") * lpeg.R("09") hvdm.date = lpeg.C(hvdm.year) * lpeg.C(hvdm.month) * lpeg.C(hvdm.day) * -1 / "%3-%2-%1" \stopluacode \def\FormatDate#1{\ctxlua{tex.print(tostring(hvdm.date:match(#1)))}}
Calling \FormatDate(1) is OK although it returns "nil" (correct would be #1 = 20101114 Calling \FormatDate(A) is not OK with the error:
You are passing a undefined variable, A. Your argument should be quoted: hvdm.date:match("#1") Regards, Khaled -- Khaled Hosny Arabic localiser and member of Arabeyes.org team Free font developer