[NTG-context] Testing value of a \def

Wolfgang Schuster schuster.wolfgang at gmail.com
Thu Feb 8 11:06:29 CET 2018


> Procházka Lukáš Ing. <mailto:LPr at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20180208/e9566989/attachment.html>


More information about the ntg-context mailing list