From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/63513 Path: news.gmane.org!not-for-mail From: Khaled Hosny Newsgroups: gmane.comp.tex.context Subject: Re: why nil argument Date: Sun, 14 Nov 2010 21:53:09 +0200 Message-ID: <20101114195309.GB21403@khaled-laptop> References: <2770E777-778C-49BC-86EF-52A65444E21C@uva.nl> <20101114192727.GA21403@khaled-laptop> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289764430 16626 80.91.229.12 (14 Nov 2010 19:53:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 14 Nov 2010 19:53:50 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Nov 14 20:53:45 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 1PHidz-0006Tp-2c for gctc-ntg-context-518@m.gmane.org; Sun, 14 Nov 2010 20:53:43 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 7666DCA83C; Sun, 14 Nov 2010 20:53:42 +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 aAjPTx0h41Is; Sun, 14 Nov 2010 20:53:38 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2FAD1CA831; Sun, 14 Nov 2010 20:53:38 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 8B520CA831 for ; Sun, 14 Nov 2010 20:53:36 +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 4KNiJLiZIgX1 for ; Sun, 14 Nov 2010 20:53:23 +0100 (CET) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id 0DA46CA824 for ; Sun, 14 Nov 2010 20:53:23 +0100 (CET) Original-Received: from mail-wy0-f169.google.com (mail-wy0-f169.google.com [74.125.82.169]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id oAEJrFKa032030 for ; Sun, 14 Nov 2010 20:53:16 +0100 Original-Received: by wyf23 with SMTP id 23so5087849wyf.14 for ; Sun, 14 Nov 2010 11:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:date:from:to:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=659pgdhSb9q5R40DCVrPoHFkXqh09Op3N0Hb7lbXu/4=; b=oYynCIi8yx+VoaJsd4N/OpsUkt9/beUDuZ71EgYEi0L/Yxn48Yc5km2gCLddHVXVx2 rJhZt8mjZNBNl3OVST42rjAkpdVr1H3b1Z+T1dJOSr4e4SoV9fRX746mwn9Tao7H9o/5 EQgKCTrDXlY1j2qgVd9UNSgNPmg2FX+bE8KBw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=BcOEAoBXvGldfK5h2E1IM3tD8Y9Rq4GpsLFB/7ZKRmdBx7pzWYpXbNZYzja9bQiaWJ FMe/IP6Zrz2kw3SyRXiQPGTViBUay3+AZbj29/BlMmjbank6nqBdL47UKoHaqLIAfc4Z Sl4NxNmOeQ/nuSJk1sZro96Z310YG7hU3IUp0= Original-Received: by 10.227.143.75 with SMTP id t11mr5183136wbu.190.1289764395155; Sun, 14 Nov 2010 11:53:15 -0800 (PST) Original-Received: from localhost ([41.238.234.163]) by mx.google.com with ESMTPS id ga16sm4529960wbb.1.2010.11.14.11.53.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 14 Nov 2010 11:53:14 -0800 (PST) Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=74.125.82.169; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0rDv7RfGD - bab5b34e0922 - 20101114 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 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:63513 Archived-At: On Sun, Nov 14, 2010 at 08:47:30PM +0100, Hans van der Meer wrote: > > On 14 nov 2010, at 20:27, Khaled Hosny wrote: > > > 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") > > > > I would think that is not the case. > For one, because then calling with argument 1 would fail in the same manner as argument A does; which does not happen. No, match(1) will match an integer 1, match("1") matches a string "1", while match(A) will match a variable A which is not what you are after, while match("A") will match a string "A". > Secondly, the call originates from > \startxmlsetups xml:case:burned > \xmldoifelsetext{#1}{}{\FormatDate{\xmlflush{#1}}}{\currentdate} > \stopxmlsetups > This does makes it a string already. TeX is not lua, the concepts are completely and totally different. > Something else must happen here, I guess. No, there isn't. Regards, Khaled -- Khaled Hosny Arabic localiser and member of Arabeyes.org team Free font developer ___________________________________________________________________________________ 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 ___________________________________________________________________________________