Re: [NTG-context] How to test the emptyness of a variable?
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 ___ 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 ___
Re: [NTG-context] How to test the emptyness of a variable?
On Thu, 7 Nov 2013, Géry Ogam wrote: 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: Why not just check the labeltext? \define[1]\MyConversion {\doifelse{#1}{1}{ONE}{#1}} \define\CheckedConversion % #1 number {\doiftextelse{\labeltexts{chapter}}\MyConversion\numbers} \defineconversion[CheckedConversion][\CheckedConversion] \setuphead[chapter][conversion=CheckedConversion] \doifmode{label}{\setuplabeltext[chapter=CHAPTER~]} \starttext \chapter{Cool} \chapter{Cat} \chapter{Mouse} \stoptext compile with and without --mode=label. Aditya___ 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 ___
Re: [NTG-context] How to test the emptyness of a variable?
Hello, Lua way: \setuplabeltext[chapter=] \define[1]\MyCommand{\ctxcommand{doifelse(1==\currentsectioncountervalue)}{ONE}{#1}} \setuphead[chapter][deepnumbercommand=\MyCommand] \starttext \chapter{Cool} \chapter{Cat} \chapter{Mouse} \stoptext I'm sure there is also a "cleaner" TeX way, but I'm not experienced enough for that. Cheers, Lukas On Tue, 05 Nov 2013 22:56:54 +0100, Géry Ogam wrote: Any idea for achieving this behaviour? - When there is a chapter label (\setuplabeltext[chapter=CHAPTER~]), display : CHAPTER ONE Cool CHAPTER 2 Cat CHAPTER 3 Mouse etc. - When there is no chapter label (\setuplabeltext[chapter=]), display: 1 Cool 2 Cat 3 Mouse etc. My try achieves the first display, but not the second one since I don’t know how to test the emptyness of the chapter label. When I remove the chapter label, it displays: ONE Cool 2 Cat 3 Mouse instead of: 1 Cool 2 Cat 3 Mouse My code: \setuplabeltext[chapter=CHAPTER~] \define[1] \MyCommand{\doifelse{\currentsectioncountervalue}{1}{ONE}{#1}} \setuphead[chapter][deepnumbercommand=\MyCommand] \starttext \chapter{Cool} \chapter{Cat} \chapter{Mouse} \stoptext -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038 t2.mkiv Description: Binary data t2.pdf Description: Adobe PDF document ___ 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 ___
Re: [NTG-context] How to test the emptyness of a variable?
On 11/5/2013 12:42 AM, Géry Ogam wrote: Hello, How to test if the current structure label is empty? The following example does not work because I don’t know how to expand the variable \currentstructurelabel.. E.g.: \define \MyCommand{\doifempty{\currentstructurelabel}{Do something}} you can try \doifnothing\currentstructurelabel{Do something} Best regards. ___ 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 ___ -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ 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 ___