From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/61605 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: Perfecting my checkbox functionalities Date: Fri, 10 Sep 2010 18:00:00 +0200 Message-ID: <69FD6C90-67F8-4F94-B461-7877DB5EB46A@gmail.com> References: <87iq2ekoq4.fsf@linux-lqcw.site> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1284134442 17786 80.91.229.12 (10 Sep 2010 16:00:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Sep 2010 16:00:42 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Sep 10 18:00:40 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 1Ou61o-00031U-5U for gctc-ntg-context-518@m.gmane.org; Fri, 10 Sep 2010 18:00:40 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 82900CA700; Fri, 10 Sep 2010 18:00:36 +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 uxbeMfmstCG5; Fri, 10 Sep 2010 18:00:36 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 16632CA6F3; Fri, 10 Sep 2010 18:00:30 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 27761CA6F3 for ; Fri, 10 Sep 2010 18:00:29 +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 BD5h2pp9f2t4 for ; Fri, 10 Sep 2010 18:00:23 +0200 (CEST) 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 B15E8CA61A for ; Fri, 10 Sep 2010 18:00:23 +0200 (CEST) Original-Received: from mail-fx0-f41.google.com (mail-fx0-f41.google.com [209.85.161.41]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o8AG0Mti021033 for ; Fri, 10 Sep 2010 18:00:23 +0200 Original-Received: by fxm3 with SMTP id 3so2237811fxm.14 for ; Fri, 10 Sep 2010 09:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=ndHUkSrqCF0ed0mdMFHg//uG/rzg5O0qPLMMkqzlS/8=; b=UvR0nrJ2BFBW6NtIHiUz8lDG/vkK4jeZO34+SVJ3oONOkWLiYmMhOu41+GPURpatTV vY432mAEm08i4R8rQ+jqVpha4PPXjIymPOajOT6q6D3XLyiRRAevcnw5SiY0fSONd/6l pYiAgFWnN8PdQxxcqJtKhXk8NLVe6z8fgCSI8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=CX1TirlQPkx6rlSeNASFaC3wOJc3aaLo0qBDyMmi8MKTqMciksI1F1mAqzmQfUmIBd LWhp/B7rEqIi4Fh2zmIiWHw7mO/3KExTNMqwT2ezBELfmdgnmwujQzrbRY/AUi8/gz2E r7QXGq//vkd1zEpFZ8XZoqivJuj4QIqARWo/s= Original-Received: by 10.223.119.82 with SMTP id y18mr588580faq.60.1284134422503; Fri, 10 Sep 2010 09:00:22 -0700 (PDT) Original-Received: from [192.168.2.23] (p5B2959F7.dip.t-dialin.net [91.41.89.247]) by mx.google.com with ESMTPS id s20sm1418407faa.4.2010.09.10.09.00.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 10 Sep 2010 09:00:08 -0700 (PDT) In-Reply-To: <87iq2ekoq4.fsf@linux-lqcw.site> X-Mailer: Apple Mail (2.1081) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.161.41; 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: 0xD540msx - 4c08776452f7 - 20100910 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:61605 Archived-At: Am 10.09.2010 um 10:05 schrieb Cecil Westerhof: > I am learning to work with ConTeXt. At the moment I have the following > defined: I guess we need a context programmers guide. > \newdimen\CheckBoxMargin > \CheckBoxMargin=3D2em > \newdimen\CheckBoxWidth > \CheckBoxWidth=3D2.5em > \newdimen\CheckBoxDistance > \CheckBoxDistance=3D.5em Get rid of this stuff and use a setup command: \def\setupCheckBox {\dodoubleargument\getrawparameters[CheckBox]} \setupCheckBox [Margin=3D2em, Width=3D2.5em, Distance=3D.5em] > \definesymbol[CheckBox][{[~~~]}] > \def\startcheckbox[#1]{ > \blank > \leftaligned{#1} > \startitemize[packed, intro, joinedup][margin=3D\CheckBoxMargin, > symbol=3DCheckBox, width=3D\CheckBoxWidth, > distance=3D\CheckBoxDistance] > } > = > \def\stopcheckbox{ > \stopitemize > \blank > \crlf > } = Brr, latex style. Why \crlf at the end of \stopcheckbox, to get a bigger sp= ace use \blank[...]. > \def\GetNiveauOfService[#1]{ > \blank > #1 {\switchtobodyfont[0.5em](1 =3D low, 9 =3D high)} > \startitemize[packed, intro, joinedup, columns][n=3D9, > symbol=3DCheckBox, width=3D\CheckBoxWidth, > distance=3D\CheckBoxDistance] > \dorecurse{9}{ > \item \recurselevel > } > \stopcheckbox > } \def\GetNiveauOfService {\dodoubleempty\doGetNiveauOfService} \def\doGetNiveauOfService[#1][#2]% {\blank #1 {\switchtobodyfont[0.5em]\doifsomethingelse{#2}{#2}{(1 =3D \translate= [en=3Dlow,nl=3Dweinig], 9 =3D \translate[en=3Dhigh,nl=3Dveel])}} \startitemize[packed,intro,joinedup,columns][n=3D9,symbol=3DCheckBox, wid= th=3D\CheckBoxWidth,distance=3D\CheckBoxDistance] \dorecurse{9}{\item \recurselevel} \stopitemize} > I have a few questions about this. > = > In GetNiveauOfService 9 is used three times. I like DRY, so I was > wondering if there would be a better way to do this? ??? (Note: I switched your following two questions) > Lastly, in GetNiveauOfService there is text. How can I make this > language dependent. For example in English I want: > (1 =3D low, 9 =3D high) > but in Dutch: > (1 =3D weinig, 9 =3D veel) > and properly it would be a good idea to have two optional parameters > when you want other descriptions. > How would I do this? See my version of the command, there is a second optional argument which can be used to set a alternative text. > Next step would be that the number of checkboxes could be a parameter. > The default would be nine and if given, the given value would be used. > How would I do this? > = > Then the 'normal' checkboxes. The default is one column. But I would > like to have the possibility to use a parameter to for example make > checkboxes in three columns. How would I do this? For the last question i showed you how you can use a optional parameter to set alternative text but as you want more and more parameter you should first think about the interface for you commands (e.g. key-value makes more sense than lots of text arguments because you can=92t make all of them optional in this case. 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 ___________________________________________________________________________= ________