From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/85183 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?G=C3=A9ry_Ogam?= Newsgroups: gmane.comp.tex.context Subject: Re: How to test the emptyness of a variable? Date: Sun, 10 Nov 2013 17:32:39 +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="===============1383086664==" X-Trace: ger.gmane.org 1384101164 7432 80.91.229.3 (10 Nov 2013 16:32:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 Nov 2013 16:32:44 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Sun Nov 10 17:32:48 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 1VfXwM-0001CS-Tl for gctc-ntg-context-518@m.gmane.org; Sun, 10 Nov 2013 17:32:46 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id BC0A31021F; Sun, 10 Nov 2013 17:32:45 +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 sANzghkfBTDc; Sun, 10 Nov 2013 17:32:44 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 28BB7101F6; Sun, 10 Nov 2013 17:32:44 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2B624101F6 for ; Sun, 10 Nov 2013 17:32:42 +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 Cv9GpLxg1k8t for ; Sun, 10 Nov 2013 17:32:40 +0100 (CET) Original-Received: from filter1-utr.mf.surf.net (filter1-utr.mf.surf.net [195.169.124.152]) by balder.ntg.nl (Postfix) with ESMTP id 69C9D101E5 for ; Sun, 10 Nov 2013 17:32:40 +0100 (CET) Original-Received: from mail-wi0-x22c.google.com (mail-wi0-x22c.google.com [IPv6:2a00:1450:400c:c05::22c]) by filter1-utr.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id rAAGWdn6002564 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sun, 10 Nov 2013 17:32:39 +0100 Original-Received: by mail-wi0-f172.google.com with SMTP id ez12so1251765wid.11 for ; Sun, 10 Nov 2013 08:32:39 -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=9bqQEThUXkIsrOwELI/O+hK83WvZKJWsnn11w4YJ65Q=; b=zXCVNivg1U8h5YlL8mYQZKCB1gBtjVRFWjv5GCjsR4PhfPZQ8+fMzi2n+kdaWOumId 5e6BMvnF3Lc6jRLdlqCWg3ZK23uZqT90ZgQuVoHrsHqv3nS7IVBGVYi95+y1Q03lWxr1 Cqq6M0uFTOd/32eYtLpdnQnDVBSLlxr/g6876BEk7/yWmH8cQcyWSgYygnYzlz4Rt0dU pdR+fYR+A6U8y1n1rVDx5ijkrwtq/tVZ0oqgbD902Gb+m1Auy2KOHUYZt8pO71OEzfeP wtLIywlsekTNTWGURektZYewWmS/aXKZqkREZoZl9wxh1suEjET5ZRxKbFbWe4D6emo0 TdwA== X-Received: by 10.194.94.137 with SMTP id dc9mr502979wjb.38.1384101159050; Sun, 10 Nov 2013 08:32:39 -0800 (PST) Original-Received: by 10.216.244.4 with HTTP; Sun, 10 Nov 2013 08:32:39 -0800 (PST) X-Bayes-Prob: 0.3394 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=2a00:1450:400c:c05::22c; country=IE X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 07KLQwDqc - ab27a8b8951d - 20131110 (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:85183 Archived-At: --===============1383086664== Content-Type: multipart/alternative; boundary=047d7bb0435ceb21cf04ead529dd --047d7bb0435ceb21cf04ead529dd Content-Type: text/plain; charset=UTF-8 Thank you very much Aditya, now it works. As you said, the trick was to use \doiftextelse{}{}{} function as test of emptyness function, and \labeltext{chapter} instead of \currentstructurelabel as variable for the test because the latter was never found empty, even when it was. Thus the right code for me is: \define[1] \MyConversion{\doifelse{\currentsectioncountervalue}{1}{\doiftextelse{\labeltext{chapter}}{ONE}{#1}}{#1}} \defineconversion[MyConversion][\MyConversion] \setuphead[chapter][conversion=MyConversion] \starttext \setuplabeltext[chapter=] \chapter{Cool} \chapter{Cat} \chapter{Mouse} \setuplabeltext[chapter=CHAPTER~] \setupheadnumber[chapter][0] \chapter{Cool} \chapter{Cat} \chapter{Mouse} \stoptext --047d7bb0435ceb21cf04ead529dd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thank you very much Aditya, now it works.

As you said, the trick was to use \doiftextelse{}{}{} function as test o= f emptyness function, and \labeltext{chapter} instead of \currentstructurel= abel as variable for the test because the latter was never found empty, eve= n when it was.

Thus the right code for me is:

\define[1]
\MyConversion{\doifelse{\currentsectioncounterva= lue}{1}{\doiftextelse{\labeltext{chapter}}{ONE}{#1}}{#1}}
\define= conversion[MyConversion][\MyConversion]
\setuphead[chapter][conversion=3DMyConversion]

\starttext

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

\setuplabeltext[chapter=3DCHAPTER~]
\setuphea= dnumber[chapter][0]
=C2=A0 =C2=A0 \chapter{Cool}
=C2=A0= =C2=A0 \chapter{Cat}
=C2=A0 =C2=A0 \chapter{Mouse}
\stoptext
--047d7bb0435ceb21cf04ead529dd-- --===============1383086664== 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 ___________________________________________________________________________________ --===============1383086664==--