From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/63510 Path: news.gmane.org!not-for-mail From: Hans van der Meer Newsgroups: gmane.comp.tex.context Subject: why nil argument Date: Sun, 14 Nov 2010 18:55:20 +0100 Message-ID: <2770E777-778C-49BC-86EF-52A65444E21C@uva.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289757339 19229 80.91.229.12 (14 Nov 2010 17:55:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 14 Nov 2010 17:55:39 +0000 (UTC) To: NTG ConTeXt Original-X-From: ntg-context-bounces@ntg.nl Sun Nov 14 18:55:33 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PHgnb-0004JV-6M for gctc-ntg-context-518@m.gmane.org; Sun, 14 Nov 2010 18:55:31 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 18BD5CA82F; Sun, 14 Nov 2010 18:55:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GRpsSZNDvHmr; Sun, 14 Nov 2010 18:55:27 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 211A0CA831; Sun, 14 Nov 2010 18:55:27 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 500B3CA831 for ; Sun, 14 Nov 2010 18:55:25 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id AKIGgztg2uGT for ; Sun, 14 Nov 2010 18:55:22 +0100 (CET) Original-Received: from filter2-til.mf.surf.net (filter2-til.mf.surf.net [194.171.167.218]) by balder.ntg.nl (Postfix) with ESMTP id D7B31CA82F for ; Sun, 14 Nov 2010 18:55:22 +0100 (CET) Original-Received: from postduif.ic.uva.nl (postduif.ic.uva.nl [145.18.40.180]) by filter2-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id oAEHtMLi014814 for ; Sun, 14 Nov 2010 18:55:22 +0100 Original-Received: from elhalyn.fritz.box (a82-95-102-36.adsl.xs4all.nl [82.95.102.36]) (authenticated bits=0) by postduif.ic.uva.nl (8.13.1/8.13.1) with ESMTP id oAEHtK5b022855 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Sun, 14 Nov 2010 18:55:21 +0100 X-Mailer: Apple Mail (2.1082) X-CanIt-Geo: ip=145.18.40.180; country=NL; region=07; city=Amsterdam; latitude=52.3500; longitude=4.9167; http://maps.google.com/maps?q=52.3500,4.9167&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0bDv5TmsI - 71c0bf48ac84 - 20101114 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.218 X-Scanned-By: CanIt (www . roaringpenguin . com) on 145.18.40.180 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:63510 Archived-At: 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: ! LuaTeX error
:1: bad argument #1 to 'match' (string expected, got nil) stack traceback: [C]: in function 'match'
:1: in main chunk. It is no problem if the function returns the string "nil" from tostring() but an error like this I would like to avoid. Hans van der Meer ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________