ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Testing value of a \def
@ 2018-02-08  9:50 Procházka Lukáš Ing.
  2018-02-08 10:06 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. @ 2018-02-08  9:50 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 682 bytes --]

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

[-- Attachment #2: Test.mkiv --]
[-- Type: application/octet-stream, Size: 179 bytes --]

\starttext
  \jobname
  \doifelse{\jobname}{Test}{Yes}{No}
  \def\T{Test}
  \ifx\jobname\T True\else False\fi
  \ctxcommand{doifelse("\jobname" == "Test")}{1}{0}
\stoptext

[-- Attachment #3: Test.pdf --]
[-- Type: application/pdf, Size: 5494 bytes --]

[-- Attachment #4: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Testing value of a \def
  2018-02-08  9:50 Testing value of a \def Procházka Lukáš Ing.
@ 2018-02-08 10:06 ` Wolfgang Schuster
  2018-02-08 12:23   ` Procházka Lukáš Ing.
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2018-02-08 10:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1222 bytes --]


> 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

[-- Attachment #1.2: Type: text/html, Size: 2310 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Testing value of a \def
  2018-02-08 10:06 ` Wolfgang Schuster
@ 2018-02-08 12:23   ` Procházka Lukáš Ing.
  0 siblings, 0 replies; 3+ messages in thread
From: Procházka Lukáš Ing. @ 2018-02-08 12:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Great, thank you!

Lukas


On Thu, 08 Feb 2018 11:06:29 +0100, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:

>
>> 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

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-08 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08  9:50 Testing value of a \def Procházka Lukáš Ing.
2018-02-08 10:06 ` Wolfgang Schuster
2018-02-08 12:23   ` Procházka Lukáš Ing.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).