Testing value of a \def
Hello, I'm trying to test whether value of \jobname is "Test"; I suppose it should be as the file name is "Test.mkiv". But the code: ---- \starttext \jobname \doifelse{\jobname}{Test}{Yes}{No} \def\T{Test} \ifx\jobname\T True\else False\fi \ctxcommand{doifelse("\jobname" == "Test")}{1}{0} \stoptext ---- yields "No", "False" and "1", so only the printed "1" is what I expect. Why \doifelse and \ifx are evaluated as false? Best regards, Lukas -- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396
Procházka Lukáš Ing. mailto:LPr@pontex.cz 8. Februar 2018 um 10:50 Hello,
I'm trying to test whether value of \jobname is "Test"; I suppose it should be as the file name is "Test.mkiv".
But the code:
---- \starttext \jobname \doifelse{\jobname}{Test}{Yes}{No} \def\T{Test} \ifx\jobname\T True\else False\fi \ctxcommand{doifelse("\jobname" == "Test")}{1}{0} \stoptext ----
yields "No", "False" and "1", so only the printed "1" is what I expect.
Why \doifelse and \ifx are evaluated as false?
The string from \jobname consists of catcode 12 letters while normal text consists of catcode 11 letters. If you need the name of the file use one of the commands below. \starttext \starttabulate \NC \tex{jobfilefullname} \NC \jobfilefullname \NC\NR \NC \tex{jobfilename} \NC \jobfilename \NC\NR \NC \tex{jobfilesuffix} \NC \jobfilesuffix \NC\NR \TB \NC \tex{inputfilebarename} \NC \inputfilebarename \NC\NR \NC \tex{inputfilerealsuffix} \NC \inputfilerealsuffix \NC\NR \NC \tex{inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \tex{inputfilename} \NC \inputfilename \NC\NR \stoptabulate \stoptext Wolfgang
Great, thank you!
Lukas
On Thu, 08 Feb 2018 11:06:29 +0100, Wolfgang Schuster
Procházka Lukáš Ing. mailto:LPr@pontex.cz 8. Februar 2018 um 10:50 Hello,
I'm trying to test whether value of \jobname is "Test"; I suppose it should be as the file name is "Test.mkiv".
But the code:
---- \starttext \jobname \doifelse{\jobname}{Test}{Yes}{No} \def\T{Test} \ifx\jobname\T True\else False\fi \ctxcommand{doifelse("\jobname" == "Test")}{1}{0} \stoptext ----
yields "No", "False" and "1", so only the printed "1" is what I expect.
Why \doifelse and \ifx are evaluated as false?
The string from \jobname consists of catcode 12 letters while normal text consists of catcode 11 letters. If you need the name of the file use one of the commands below.
\starttext
\starttabulate \NC \tex{jobfilefullname} \NC \jobfilefullname \NC\NR \NC \tex{jobfilename} \NC \jobfilename \NC\NR \NC \tex{jobfilesuffix} \NC \jobfilesuffix \NC\NR \TB \NC \tex{inputfilebarename} \NC \inputfilebarename \NC\NR \NC \tex{inputfilerealsuffix} \NC \inputfilerealsuffix \NC\NR \NC \tex{inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \tex{inputfilename} \NC \inputfilename \NC\NR \stoptabulate
\stoptext
Wolfgang
-- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn Bezová 1658 147 14 Praha 4 Mob.: +420 702 033 396
participants (2)
-
Procházka Lukáš Ing.
-
Wolfgang Schuster