From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/73639 Path: news.gmane.org!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: Re: How to define a command... Date: Thu, 5 Jan 2012 22:24:06 +0100 Message-ID: <43565B01-31F5-41C8-AF85-60AFA0826805@gmail.com> References: <6457E519-6F30-482B-98DC-08BD546F8B2F@gmail.com> <8739btj455.fsf@micropit.couberia.bzh> 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="windows-1252" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1325798674 18028 80.91.229.12 (5 Jan 2012 21:24:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2012 21:24:34 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jan 05 22:24:30 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 1RiunU-0007RF-R1 for gctc-ntg-context-518@m.gmane.org; Thu, 05 Jan 2012 22:24:28 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 741E1CB1EB; Thu, 5 Jan 2012 22:24:27 +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 D5FnZRxs7cQe; Thu, 5 Jan 2012 22:24:25 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id CD426CB1DD; Thu, 5 Jan 2012 22:24:24 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6926DCB1DD for ; Thu, 5 Jan 2012 22:24:24 +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 TmynMa6uSqgB for ; Thu, 5 Jan 2012 22:24:13 +0100 (CET) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id 690ADCB1DC for ; Thu, 5 Jan 2012 22:24:13 +0100 (CET) Original-Received: from mail-we0-f169.google.com (mail-we0-f169.google.com [74.125.82.169]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q05LOAeI015955 for ; Thu, 5 Jan 2012 22:24:10 +0100 Original-Received: by werf1 with SMTP id f1so963736wer.14 for ; Thu, 05 Jan 2012 13:24:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=c6IfVC7nDx8X04w2DxOnUvNXUq+Vw9KMkpNyVDLD8oM=; b=NTimnjey1ce8fChwM8ZKdHn/Jstrp/r6yKra64ePec1ARcPKeqcDr4iDLQJc6bkm4q SjyjO11xG+9XkJ242X+wlIWXqSswRZUcn1ihJJQxnvLS2jaykZOfYwlI7tV8xpX0NGrP B20DUkzmw+wynuxsr4kXlHOhwni4+TYjIzYdU= Original-Received: by 10.216.132.231 with SMTP id o81mr2137696wei.3.1325798650563; Thu, 05 Jan 2012 13:24:10 -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 gf8sm17110958wbb.11.2012.01.05.13.24.09 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jan 2012 13:24:09 -0800 (PST) In-Reply-To: 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: 0HGhVoa8f - 2ba33c576c3b - 20120105 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 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:73639 Archived-At: Hi again Wolfgang and Peter, The solution you provided to my problem is great but has a small issue=85 Considering the definition \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } after saying = \RandomCoeff{Alpha}{1}{10} one gets \CoeffAlpha, but if I use several times \CoeffAlpha, it takes a ne= w value each time, an effect which is undesirable in what I am willing to d= o. Is there a way to somehow =AB freeze =BB the value of \CoeffAlpha once it i= s defined? Best regards: OK PS: here is the complete example: \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}} } \starttext \RandomCoeff{Alpha}{1}{10} \RandomCoeff{Beta}{10}{100} \CoeffAlpha \CoeffBeta \CoeffAlpha \CoeffBeta \stoptext On 5 janv. 2012, at 21:18, Wolfgang Schuster wrote: > = > Am 05.01.2012 um 21:17 schrieb Peter M=FCnster: > = >> On Thu, Jan 05 2012, Otared Kavian wrote: >> = >>> \define[3]\RandomCoeff{% >>> \ctxlua{a =3D math.random(#2,#3)} >>> % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does n= ot work as expected... >> = >> \setuprandomize[2012] >> \define[3]\RandomCoeff{% >> \expandafter\def\csname Coeff#1\endcsname{\ctxlua{tex.print(math.random(= #2,#3))}}} > = > \setvalue{Coeff#1}{=85} > = > Wolfgang ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________