ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \jobname and \doifelse
@ 2022-11-05 15:30 Pablo Rodriguez via ntg-context
  2022-11-05 15:55 ` Wolfgang Schuster via ntg-context
  2022-11-06 10:21 ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-11-05 15:30 UTC (permalink / raw)
  To: ConTeXt users; +Cc: Pablo Rodriguez

Dear list,

using current latest (2022.10.22 11:23), I have the following sample:

  \starttext
  \doifelse{\jobname}{a}
    {yes}{no}
  \jobname

  \startluacode
  if tex.jobname == "a" then
    context("yes")
  else
    context("no")
  end
  \stopluacode
  \stoptext

I get "no" as in TeX and "yes" with Lua, being "a.tex" the source file.

The TeX conditional used to work before.

Am I missing something or have I hit a bug?

I’m on Linux64 (if this may be relevant).

Many thanks for your help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: \jobname and \doifelse
  2022-11-05 15:30 \jobname and \doifelse Pablo Rodriguez via ntg-context
@ 2022-11-05 15:55 ` Wolfgang Schuster via ntg-context
  2022-11-06 13:11   ` Pablo Rodriguez via ntg-context
  2022-11-06 10:21 ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-11-05 15:55 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Pablo Rodriguez via ntg-context
  Cc: Wolfgang Schuster, Pablo Rodriguez

Pablo Rodriguez via ntg-context schrieb am 05.11.2022 um 16:30:
> Dear list,
>
> using current latest (2022.10.22 11:23), I have the following sample:
>
>    \starttext
>    \doifelse{\jobname}{a}
>      {yes}{no}
>    \jobname
>
>    \startluacode
>    if tex.jobname == "a" then
>      context("yes")
>    else
>      context("no")
>    end
>    \stopluacode
>    \stoptext
>
> I get "no" as in TeX and "yes" with Lua, being "a.tex" the source file.
>
> The TeX conditional used to work before.
>
> Am I missing something or have I hit a bug?

Are you sure the check worked in the past?

The content of \jobname has catcode 12 while you "a" you check against 
has catcode 11, and even when \jobname result in "a" they are different 
because the catcodes differ.

You can see the same result in the example below where the second check 
compares two a with different catcodes (11 and 12) while the first check 
has the same catcode (11) for both a's.

\starttext

\edef\A{a}
\edef\B{a}

\ifx\A\B
     yes
\else
     no
\fi

\begingroup
     \catcode`a=12
     \gdef\B{a}
\endgroup

\ifx\A\B
     yes
\else
     no
\fi

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: \jobname and \doifelse
  2022-11-05 15:30 \jobname and \doifelse Pablo Rodriguez via ntg-context
  2022-11-05 15:55 ` Wolfgang Schuster via ntg-context
@ 2022-11-06 10:21 ` Hans Hagen via ntg-context
  2022-11-06 13:12   ` Pablo Rodriguez via ntg-context
  1 sibling, 1 reply; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2022-11-06 10:21 UTC (permalink / raw)
  To: Pablo Rodriguez via ntg-context; +Cc: Hans Hagen

On 11/5/2022 4:30 PM, Pablo Rodriguez via ntg-context wrote:
> Dear list,
> 
> using current latest (2022.10.22 11:23), I have the following sample:
> 
>    \starttext
>    \doifelse{\jobname}{a}
>      {yes}{no}
>    \jobname
> 
>    \startluacode
>    if tex.jobname == "a" then
>      context("yes")
>    else
>      context("no")
>    end
>    \stopluacode
>    \stoptext
> 
> I get "no" as in TeX and "yes" with Lua, being "a.tex" the source file.
> 
> The TeX conditional used to work before.
> 
> Am I missing something or have I hit a bug?
> 
> I’m on Linux64 (if this may be relevant).
More relevan tis that you'r on TeX where catcodes matter
(here letter vs other)

   \doifelse{\inputfilebarename}{oeps}
     {yes}{no}

   \doifelse{\detokenize\expandafter{\jobname}}{\detokenize{oeps}}
     {yes}{no}


Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: \jobname and \doifelse
  2022-11-05 15:55 ` Wolfgang Schuster via ntg-context
@ 2022-11-06 13:11   ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-11-06 13:11 UTC (permalink / raw)
  To: Wolfgang Schuster via ntg-context; +Cc: Pablo Rodriguez

On 11/5/22 16:55, Wolfgang Schuster via ntg-context wrote:
> Pablo Rodriguez via ntg-context schrieb am 05.11.2022 um 16:30:
>>
>>    \doifelse{\jobname}{a}
>>      {yes}{no}
>>
>> I get "no" as in TeX and "yes" with Lua, being "a.tex" the source file.
>>
>> The TeX conditional used to work before.
>>
> Are you sure the check worked in the past?

Many thanks for your reply, Wolfgang.

I thought this used to work before.

Now I realize I have to check the use of \doif{\jobname} and
\doifelse{\jobname} in all my documents.

> The content of \jobname has catcode 12 while you "a" you check against 
> has catcode 11, and even when \jobname result in "a" they are different 
> because the catcodes differ.

I see now. Not that I fully understand what catcodes are, but
\doifsamestringelse should be what I have used here (as suggested in
https://wiki.contextgarden.net/System_Macros/Branches_and_Decisions#.5Cdoifsamestringelse.2C.5Cdoifsamestring.2C.5Cdoifnotsamestring).

Just a final question: \doif compares both strings and catcodes and
\doifsamestring compares only strings. Or am I missing something here too.

Many thanks for your help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: \jobname and \doifelse
  2022-11-06 10:21 ` Hans Hagen via ntg-context
@ 2022-11-06 13:12   ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-11-06 13:12 UTC (permalink / raw)
  To: Hans Hagen via ntg-context; +Cc: Pablo Rodriguez

On 11/6/22 11:21, Hans Hagen via ntg-context wrote:
> [...]
> More relevan tis that you'r on TeX where catcodes matter
> (here letter vs other)
> 
>    \doifelse{\inputfilebarename}{oeps}
>      {yes}{no}
> 
>    \doifelse{\detokenize\expandafter{\jobname}}{\detokenize{oeps}}
>      {yes}{no}

Many thanks for your explanation, Hans.

I think I have to start studying basic notions in TeX.

Many thanks for your help again,

Pablo

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2022-11-06 13:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05 15:30 \jobname and \doifelse Pablo Rodriguez via ntg-context
2022-11-05 15:55 ` Wolfgang Schuster via ntg-context
2022-11-06 13:11   ` Pablo Rodriguez via ntg-context
2022-11-06 10:21 ` Hans Hagen via ntg-context
2022-11-06 13:12   ` Pablo Rodriguez via ntg-context

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