From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/73638 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 21:42:48 +0100 Message-ID: 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 1325796192 589 80.91.229.12 (5 Jan 2012 20:43:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 Jan 2012 20:43:12 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jan 05 21:43:08 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 1Riu9U-0004bk-Fh for gctc-ntg-context-518@m.gmane.org; Thu, 05 Jan 2012 21:43:08 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 945F1CB1E2; Thu, 5 Jan 2012 21:43:07 +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 lVk-08BaGqSP; Thu, 5 Jan 2012 21:43:04 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D4269CB1D5; Thu, 5 Jan 2012 21:43:04 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 81DC6CB1D5 for ; Thu, 5 Jan 2012 21:43:03 +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 zQoD50JdEqAY for ; Thu, 5 Jan 2012 21:42:52 +0100 (CET) Original-Received: from filter1-ams.mf.surf.net (filter1-ams.mf.surf.net [192.87.102.69]) by balder.ntg.nl (Postfix) with ESMTP id 3F63BCB1D2 for ; Thu, 5 Jan 2012 21:42:52 +0100 (CET) Original-Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by filter1-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q05KgpLm024685 for ; Thu, 5 Jan 2012 21:42:51 +0100 Original-Received: by wibhq12 with SMTP id hq12so935627wib.14 for ; Thu, 05 Jan 2012 12:42:51 -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=2rc32fePalUPeJTnJ7nXZtQroixXs7hxIipMBni06VA=; b=rMgwdAwNmltqw4awsCTsdtgY6rQdw3ZpzR8xEIWmU9EhVOtksd4o0woQEDJ8cIYAAP 7vopIonBh2fmkhIA/avME5+vKemRdEMPDM+XNWg99UPtm4H4mLNYwgy0FfjOVfjhl/Yw RRzrAhiwg01HmYyc3hNLcPgQyd8bnYeqXjuT4= Original-Received: by 10.180.94.102 with SMTP id db6mr1780743wib.0.1325796171544; Thu, 05 Jan 2012 12:42:51 -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 em13sm1101805wid.7.2012.01.05.12.42.50 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jan 2012 12:42:50 -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=209.85.212.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: 06GhUGP44 - 4bd7e8c28fa9 - 20120105 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.69 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:73638 Archived-At: Thanks for Wolfgang: your solution, that is \setuprandomize[2012] \define[3]\RandomCoeff{% \setvalue{Coeff#1}{\ctxlua{tex.print(math.random(#2,#3))}}} works indeed and it is somehow simpler than using \expandafter\csname, and = as a matter of fact, after reading your message I searched in the ConTeXt m= anuals written by Hans, and found that \setvalue is defined on page 93 of m= odule-01.pdf as = \def\setvalue#1{\expandafter \def\csname#1\endcsname} so it is better to use it. Best regards: OK 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 ___________________________________________________________________________= ________