From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/73631 Path: news.gmane.org!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: How to define a command... Date: Thu, 5 Jan 2012 21:05:53 +0100 Message-ID: <6457E519-6F30-482B-98DC-08BD546F8B2F@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1325793984 16927 80.91.229.12 (5 Jan 2012 20:06:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2012 20:06:24 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jan 05 21:06:20 2012 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 1RitZq-0002HA-VW for gctc-ntg-context-518@m.gmane.org; Thu, 05 Jan 2012 21:06:19 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id ED320CB1DB; Thu, 5 Jan 2012 21:06:16 +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 1xTUA0698t52; Thu, 5 Jan 2012 21:06:14 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 15BBFCB1D5; Thu, 5 Jan 2012 21:06:14 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 1C3AFCB1D5 for ; Thu, 5 Jan 2012 21:06:13 +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 yjXpGYJzrHIJ for ; Thu, 5 Jan 2012 21:05:58 +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 48035CB1D2 for ; Thu, 5 Jan 2012 21:05:58 +0100 (CET) Original-Received: from mail-we0-f169.google.com (mail-we0-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 q05K5vHM022589 for ; Thu, 5 Jan 2012 21:05:57 +0100 Original-Received: by werf1 with SMTP id f1so897523wer.14 for ; Thu, 05 Jan 2012 12:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; bh=NilES0AIDMRqPxsh/fNx6sdKFUeyeqgk569/PHlc2RI=; b=YSnb6/2zSPyHafahbwUZqCbc4aUR3yEudEdNmidrLm8b2E8nucxOvg7SBmXks6aJZ9 zGB+BS7U2IHtupz2cJjfT/LLQot/AUKvbpnSWMOQ0P11uxbM1OclKt61qY8MCtea8lpp coBPwWlDffOp4sgBUjVQRwAezYcTnw8TeKw4M= Original-Received: by 10.216.132.199 with SMTP id o49mr1902998wei.50.1325793957007; Thu, 05 Jan 2012 12:05:57 -0800 (PST) Original-Received: from [192.168.0.11] (seg75-6-82-236-32-4.fbx.proxad.net. [82.236.32.4]) by mx.google.com with ESMTPS id bj10sm1029992wib.9.2012.01.05.12.05.55 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jan 2012 12:05:55 -0800 (PST) X-Mailer: Apple Mail (2.1251.1) 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: 0rGhU5VH9 - 914ef14e663b - 20120105 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:73631 Archived-At: Hi all, I need to define numerical coefficients (essentially at random) and then use them with commands, say like \CoeffAlpha, \CoeffBeta, and so on. More precisely, how can I define the command \RandomCoeff, so that \RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a random number chosen between 1 and 10? I tried to use the following approach, but could not make it work: %%% begin random-coeff.tex \setuprandomize[2012] % set a seed \ctxlua{CoeffAlpha = math.random(1,10) ;} \def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}} %%%%% \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... } \starttext \CoeffAlpha \RandomCoeff{Beta}{1}{10} \ctxlua{tex.print(a)} %\CoeffBeta \stoptext %%% end random-coeff.tex Thanks in advance for any suggestion or hint. Best regards: OK ___________________________________________________________________________________ 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 ___________________________________________________________________________________