ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* comparing strings
@ 2015-09-17 16:47 Pablo Rodriguez
  2015-09-17 17:26 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Rodriguez @ 2015-09-17 16:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,

I have the following sample:

\startluacode
function document.gouppercase(str)
    tex.print(str:upper())
end
\stopluacode

\unexpanded\def\MyUpper#1%
    {\ctxlua{document.gouppercase("#1")}}

\starttext
\doif{\MyUpper{adfalkjfaeñf}}{\MyUpper{aDFAlkjfaeñf}}{equal}{unequal}

\ctxlua{if string.upper("adfalkjfaeñf") == string.upper("aDFAlkjfaeñf")
then tex.print("equal") else tex.print("unequal") end}
\stoptext

Why are are the first two strings unequal?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: comparing strings
  2015-09-17 16:47 comparing strings Pablo Rodriguez
@ 2015-09-17 17:26 ` Wolfgang Schuster
  2015-09-17 17:51   ` Pablo Rodriguez
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2015-09-17 17:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

> Pablo Rodriguez <mailto:oinos@gmx.es>
> 17. September 2015 18:47
> Dear list,
>
> I have the following sample:
>
> \startluacode
> function document.gouppercase(str)
> tex.print(str:upper())
> end
> \stopluacode
>
> \unexpanded\def\MyUpper#1%
> {\ctxlua{document.gouppercase("#1")}}
>
> \starttext
> \doif{\MyUpper{adfalkjfaeñf}}{\MyUpper{aDFAlkjfaeñf}}{equal}{unequal}
>
> \ctxlua{if string.upper("adfalkjfaeñf") == string.upper("aDFAlkjfaeñf")
> then tex.print("equal") else tex.print("unequal") end}
> \stoptext
>
> Why are are the first two strings unequal?
You can’t use a unexpandable (which you created with \unexpanded) in 
ConTeXts \doifXXX commands.

PS. You need \doifelse and not \doif.

Wolfgang

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: comparing strings
  2015-09-17 17:26 ` Wolfgang Schuster
@ 2015-09-17 17:51   ` Pablo Rodriguez
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Rodriguez @ 2015-09-17 17:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 09/17/2015 07:26 PM, Wolfgang Schuster wrote:
>> Pablo Rodriguez 17. September 2015 18:47
>> [...]
>> \unexpanded\def\MyUpper#1%
>> {\ctxlua{document.gouppercase("#1")}}
>>
>> \starttext
>> \doif{\MyUpper{adfalkjfaeñf}}{\MyUpper{aDFAlkjfaeñf}}{equal}{unequal}
>>
>> Why are are the first two strings unequal?
>
> You can’t use a unexpandable (which you created with \unexpanded) in
> ConTeXts \doifXXX commands.

Many thanks for your reply, Wolfgang.

I see. I thought it was better to add \unexpanded before a pure \def.

Is it \unexpaded required before a \def with more than one argument?

(Sorry, but expansion is a concept which I’m not familiar with.)

> PS. You need \doifelse and not \doif.

I realized this too sending the message to the list.



Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2015-09-17 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 16:47 comparing strings Pablo Rodriguez
2015-09-17 17:26 ` Wolfgang Schuster
2015-09-17 17:51   ` Pablo Rodriguez

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