ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Khaled Hosny <khaledhosny@eglug.org>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: why nil argument
Date: Sun, 14 Nov 2010 21:27:27 +0200	[thread overview]
Message-ID: <20101114192727.GA21403@khaled-laptop> (raw)
In-Reply-To: <2770E777-778C-49BC-86EF-52A65444E21C@uva.nl>

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
___________________________________________________________________________________
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
___________________________________________________________________________________


  reply	other threads:[~2010-11-14 19:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-14 17:55 Hans van der Meer
2010-11-14 19:27 ` Khaled Hosny [this message]
2010-11-14 19:47   ` Hans van der Meer
2010-11-14 19:53     ` Khaled Hosny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101114192727.GA21403@khaled-laptop \
    --to=khaledhosny@eglug.org \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).