From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/57606 Path: news.gmane.org!not-for-mail From: Peter =?utf-8?Q?M=C3=BCnster?= Newsgroups: gmane.comp.tex.context Subject: Re: arguments to ctxlua Date: Tue, 30 Mar 2010 20:30:42 +0200 Message-ID: <20100330183042.GA15195@gaston.couberia.bzh> References: 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 1269973861 30361 80.91.229.12 (30 Mar 2010 18:31:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 30 Mar 2010 18:31:01 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Mar 30 20:30:52 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 1NwgDE-0004r5-28 for gctc-ntg-context-518@m.gmane.org; Tue, 30 Mar 2010 20:30:52 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AC241C9DCD; Tue, 30 Mar 2010 20:30:51 +0200 (CEST) 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 YwSBsCzaohjX; Tue, 30 Mar 2010 20:30:51 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 83DF7C9DC6; Tue, 30 Mar 2010 20:30:48 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id BF255C9DC6 for ; Tue, 30 Mar 2010 20:30:46 +0200 (CEST) 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 663mLisppy8a for ; Tue, 30 Mar 2010 20:30:44 +0200 (CEST) Original-Received: from smtp20.orange.fr (smtp20.orange.fr [80.12.242.26]) by balder.ntg.nl (Postfix) with ESMTP id 6D146C9DC5 for ; Tue, 30 Mar 2010 20:30:44 +0200 (CEST) Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2003.orange.fr (SMTP Server) with ESMTP id 23DFF20007BF for ; Tue, 30 Mar 2010 20:30:44 +0200 (CEST) Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2003.orange.fr (SMTP Server) with ESMTP id 16105200071B for ; Tue, 30 Mar 2010 20:30:44 +0200 (CEST) Original-Received: from gaston.couberia.bzh (ARennes-551-1-110-112.w92-129.abo.wanadoo.fr [92.129.65.112]) by mwinf2003.orange.fr (SMTP Server) with ESMTP id DC26920007BF for ; Tue, 30 Mar 2010 20:30:43 +0200 (CEST) X-ME-UUID: 20100330183043901.DC26920007BF@mwinf2003.orange.fr Original-Received: by gaston.couberia.bzh (Postfix, from userid 1000) id 375C4301DC; Tue, 30 Mar 2010 20:30:43 +0200 (CEST) Mail-Followup-To: mailing list for ConTeXt users Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) 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:57606 Archived-At: On Tue, Mar 30 2010, Hans van der Meer wrote: > called through: > \def\callf#1#2{\ctxlua{f("#1","#2")}} > > and do this actually with one argument: > \callf{one} > > then I find that the absent argument b in f(a,b) is not nil but a string of > length 1. Hello Hans, You want probably something like this: \startluacode userdata = userdata or {} function userdata.f(a, b) b = b or "default value" tex.print(string.format("a = '%s' and b = '%s'\\par", a, b)) end \stopluacode \def\callf{\dodoubleempty\docallf} \def\docallf[#1][#2]{\ctxlua{userdata.f("#1"\ifsecondargument, "#2"\fi)}} \starttext \callf[one] \callf[one][two] \callf[one][] \callf[][] \callf[][two] \callf[] \stoptext Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/ ___________________________________________________________________________________ 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 ___________________________________________________________________________________