From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/85137 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?G=C3=A9ry_Ogam?= Newsgroups: gmane.comp.tex.context Subject: How to test the emptyness of a variable? Date: Thu, 7 Nov 2013 18:45:06 +0100 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2077044701==" X-Trace: ger.gmane.org 1383846309 3031 80.91.229.3 (7 Nov 2013 17:45:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Nov 2013 17:45:09 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Thu Nov 07 18:45:16 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VeTdq-0001bv-Hv for gctc-ntg-context-518@m.gmane.org; Thu, 07 Nov 2013 18:45:14 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 7F1CB101E7; Thu, 7 Nov 2013 18:45: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 5d98rO1JDJLh; Thu, 7 Nov 2013 18:45:11 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 7ED53101EA; Thu, 7 Nov 2013 18:45:11 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C9A38101EA for ; Thu, 7 Nov 2013 18:45:09 +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 i14Zw2PqiNvo for ; Thu, 7 Nov 2013 18:45:08 +0100 (CET) Original-Received: from filter4-ams.mf.surf.net (filter4-ams.mf.surf.net [192.87.102.72]) by balder.ntg.nl (Postfix) with ESMTP id 3CE3F101E7 for ; Thu, 7 Nov 2013 18:45:07 +0100 (CET) Original-Received: from mail-wg0-x232.google.com (mail-wg0-x232.google.com [IPv6:2a00:1450:400c:c00::232]) by filter4-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id rA7HpRhR003167 for ; Thu, 7 Nov 2013 18:51:27 +0100 Original-Received: by mail-wg0-f50.google.com with SMTP id n12so873157wgh.17 for ; Thu, 07 Nov 2013 09:45:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7dEj3CzHeB56TwFTnjLKFjaBxyH9uFb93w3FvForqdQ=; b=egas2pxckbGmvfjzC+597THymLDb2siC25kbNaSFmbIEfw7NC7654FCFYJkw+xnLO5 qw1WTtuaWGw3vfxTOUyps7A0XpJff4xxFmVzvWSBnUdu0L3VMeJz/Sq98jAU/jijnFAO xwFw6ogalttiFXWlajtYn2hutzPwOPm40xNk7jKfuwR8hkp5pdSYkBSa+aWbLm2RdeTn LOiAhxCNNKm5BRvzaLLQSEcJHOmQNNCTA3+v7Vk0NP+KSHrBxlIBnX7U6pvU2yugyoQt MgbkdNfnBpflb/gHcx8NJpy8clYHssi/yGw1NObm+1tPLl746Nviou750kotx5ni93Nx ubxw== X-Received: by 10.194.241.228 with SMTP id wl4mr8576230wjc.2.1383846306953; Thu, 07 Nov 2013 09:45:06 -0800 (PST) Original-Received: by 10.216.244.4 with HTTP; Thu, 7 Nov 2013 09:45:06 -0800 (PST) X-Bayes-Prob: 0.0415 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=2a00:1450:400c:c00::232; country=IE X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 01KKFPrE2 - a0b801608cd3 - 20131107 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:85137 Archived-At: --===============2077044701== Content-Type: multipart/alternative; boundary=089e01493c328cc11804ea99d300 --089e01493c328cc11804ea99d300 Content-Type: text/plain; charset=UTF-8 > I'm sure there is also a "cleaner" TeX way, but I'm not experienced enough for that. I think you misunderstood my issue: your Lua way does the same thing than my TeX way: it displays: ONE Cool 2 Cat 3 Mouse but that is NOT what I want. What I want is: 1 Cool 2 Cat 3 Mouse So I need to check if the chapter label has been set empty or not by the user, because it is not empty (let's say the user chose the string "CHAPTER~" for the chapter label) I want to display this: CHAPTER ONE Cool CHAPTER 2 Cat CHAPTER 3 Mouse The way to do that is to check if the variable \currentstructurelabel is empty, so the code must be: \define[1] \MyCommand{\doifelse{\currentsectioncountervalue}{1}{\doifnotemptyelse{\currentstructurelabel}{ONE}{#1}}{#1}} \setuphead[chapter][deepnumbercommand=\MyCommand] \starttext \setuplabeltext[chapter=CHAPTER~] \chapter{Cool} \chapter{Cat} \chapter{Mouse} \stoptext \starttext \setuplabeltext[chapter=] \chapter{Cool} \chapter{Cat} \chapter{Mouse} \stoptext But the problem is that in the second case, even if the chapter label is set empty the command \doifnotemptyelse{\currentstructurelabel} thinks the variable \currentstructurelabel is not empty. So there must be something invisible in it, like a strut or something. --089e01493c328cc11804ea99d300 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> I'm sure there is also a "cleaner" TeX = way, but I'm not experienced enough for that.

I thin= k you misunderstood my issue: your Lua way does the same thing than my TeX = way: it displays:

ONE Cool
2 Cat
3 Mouse

but that is NOT what I want. What I want is:

1 C= ool
2 Cat
3 Mouse

So I need to= check if the chapter label has been set empty or not by the user, because = it is not empty (let's say the user chose the string "CHAPTER~&quo= t; for the chapter label) I want to display this:

CHAPTER ONE Cool
CHAPTER 2 Cat
CHAP= TER 3 Mouse

The way to do that is to check if the = variable \currentstructurelabel is empty, so the code must be:

\define[1] \MyCommand{\doifelse{\currentsectioncountervalue}= {1}{\doifnotemptyelse{\currentstructurelabel}{ONE}{#1}}{#1}}
\set= uphead[chapter][deepnumbercommand=3D\MyCommand]

\starttext
=C2=A0 =C2=A0 \setuplabeltext[chapter=3DCHAPTER~]
<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \chapter{Cool}
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 \chapter{Cat}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \chap= ter{Mouse}
\stoptext

\starttext
=C2=A0 =C2=A0 \setuplabeltext[chapter=3D]
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 \chapter{Cool}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \= chapter{Cat}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 \chapter{Mouse}
\stoptext

But the problem is that in the second case,= even if the chapter label is set empty the command \doifnotemptyelse{\curr= entstructurelabel} thinks the variable \currentstructurelabel is not empty.= So there must be something invisible in it, like a strut or something.
--089e01493c328cc11804ea99d300-- --===============2077044701== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============2077044701==--