ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* What is changed?
@ 2013-02-04 18:11 H. van der Meer
  2013-02-04 18:13 ` Aditya Mahajan
  0 siblings, 1 reply; 5+ messages in thread
From: H. van der Meer @ 2013-02-04 18:11 UTC (permalink / raw)
  To: ConTeXt NTG

The following worked without a hitch:

\def\IsNilReturn#1{\edef\tmp{#1}\doifelse{\tmp}{nil}{\color[red]{ERROR}}{\tmp}}
\def\formatDuration#1{\ctxlua{
	local s = string.gsub("#1","\%D","")
	local d = tostring(hvdm.time:match(s))
	tex.print(string.sub(d,1,2) ~= "0:" and d or string.sub(d,3))
	}}
\def\FormatDuration#1{\IsNilReturn{\formatDuration{#1}}}
Called by something like \FormatDuration{11929} (meaning: 1 hour 19 minutes 29 seconds)

Now I get an error in
ConTeXt  ver: 2013.01.27 21:24 MKIV  fmt: 2013.1.28  int: english/english
! LuaTeX error [string "\directlua "]:1: invalid escape sequence near '\%'.
\formatDuration ...0:" and d or string.sub(d,3)) }                                             
\IsNilReturn #1->\edef \tmp {#1
                               }\doifelse {\tmp }{nil}{\color [red]{ERROR}}{...

Whereas in a previous Context all went well:
ConTeXt  ver: 2012.05.30 11:26 MKIV  fmt: 2013.2.4  int: english/english

What did change? Why? And how to repair?

Hans van der Meer



___________________________________________________________________________________
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] 5+ messages in thread

* Re: What is changed?
  2013-02-04 18:11 What is changed? H. van der Meer
@ 2013-02-04 18:13 ` Aditya Mahajan
  2013-02-04 18:26   ` Meer H. van der
  0 siblings, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2013-02-04 18:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 4 Feb 2013, H. van der Meer wrote:

> The following worked without a hitch:
>
> \def\IsNilReturn#1{\edef\tmp{#1}\doifelse{\tmp}{nil}{\color[red]{ERROR}}{\tmp}}
> \def\formatDuration#1{\ctxlua{
> 	local s = string.gsub("#1","\%D","")
> 	local d = tostring(hvdm.time:match(s))
> 	tex.print(string.sub(d,1,2) ~= "0:" and d or string.sub(d,3))
> 	}}
> \def\FormatDuration#1{\IsNilReturn{\formatDuration{#1}}}
> Called by something like \FormatDuration{11929} (meaning: 1 hour 19 minutes 29 seconds)
>
> Now I get an error in
> ConTeXt  ver: 2013.01.27 21:24 MKIV  fmt: 2013.1.28  int: english/english
> ! LuaTeX error [string "\directlua "]:1: invalid escape sequence near '\%'.
> \formatDuration ...0:" and d or string.sub(d,3)) }
> \IsNilReturn #1->\edef \tmp {#1
>                               }\doifelse {\tmp }{nil}{\color [red]{ERROR}}{...
>
> Whereas in a previous Context all went well:
> ConTeXt  ver: 2012.05.30 11:26 MKIV  fmt: 2013.2.4  int: english/english
>
> What did change? Why? And how to repair?

I noticed something similar a few days ago. IIRC, using \letterpercent 
still works (untested).

Aditya
___________________________________________________________________________________
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] 5+ messages in thread

* Re: What is changed?
  2013-02-04 18:13 ` Aditya Mahajan
@ 2013-02-04 18:26   ` Meer H. van der
  2013-02-04 19:12     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Meer H. van der @ 2013-02-04 18:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


On 4 feb. 2013, at 19:13, Aditya Mahajan <adityam@umich.edu>
 wrote:

> On Mon, 4 Feb 2013, H. van der Meer wrote:
> 
>> The following worked without a hitch:
>> 
>> \def\IsNilReturn#1{\edef\tmp{#1}\doifelse{\tmp}{nil}{\color[red]{ERROR}}{\tmp}}
>> \def\formatDuration#1{\ctxlua{
>> 	local s = string.gsub("#1","\%D","")
>> 	local d = tostring(hvdm.time:match(s))
>> 	tex.print(string.sub(d,1,2) ~= "0:" and d or string.sub(d,3))
>> 	}}
>> \def\FormatDuration#1{\IsNilReturn{\formatDuration{#1}}}
>> Called by something like \FormatDuration{11929} (meaning: 1 hour 19 minutes 29 seconds)
>> 
>> Now I get an error in
>> ConTeXt  ver: 2013.01.27 21:24 MKIV  fmt: 2013.1.28  int: english/english
>> ! LuaTeX error [string "\directlua "]:1: invalid escape sequence near '\%'.
>> \formatDuration ...0:" and d or string.sub(d,3)) }
>> \IsNilReturn #1->\edef \tmp {#1
>>                              }\doifelse {\tmp }{nil}{\color [red]{ERROR}}{...
>> 
>> Whereas in a previous Context all went well:
>> ConTeXt  ver: 2012.05.30 11:26 MKIV  fmt: 2013.2.4  int: english/english
>> 
>> What did change? Why? And how to repair?
> 
> I noticed something similar a few days ago. IIRC, using \letterpercent still works (untested).
> 
> Aditya

No, that is not the solution. Maybe because the % has to function in a Lua gsub as match pattern.

I tried dropping the backslash, not \%D but using %D. Then the error is:
! LuaTeX error [string "\directlua "]:1: ')' expected near '0'.
\formatDuration ...0:" and d or string.sub(d,3)) }                                                 
\IsNilReturn #1->\edef \tmp {#1
                               }\doifelse {\tmp }{nil}{\color [red]{ERROR}}{...

More ideas?


Hans van der Meer

___________________________________________________________________________________
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] 5+ messages in thread

* Re: What is changed?
  2013-02-04 18:26   ` Meer H. van der
@ 2013-02-04 19:12     ` Wolfgang Schuster
  2013-02-04 19:13       ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2013-02-04 19:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.02.2013 um 19:26 schrieb "Meer H. van der" <H.vanderMeer@uva.nl>:

> More ideas?

Move the Lua code to a luacode block or a external and use TeX only to access the function.

Wolfgang
___________________________________________________________________________________
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] 5+ messages in thread

* Re: What is changed?
  2013-02-04 19:12     ` Wolfgang Schuster
@ 2013-02-04 19:13       ` Wolfgang Schuster
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2013-02-04 19:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.02.2013 um 20:12 schrieb Wolfgang Schuster <wolfgang.schuster@gmail.com>:

> 
> Am 04.02.2013 um 19:26 schrieb "Meer H. van der" <H.vanderMeer@uva.nl>:
> 
>> More ideas?
> 
> Move the Lua code to a luacode block or a external and use TeX only to access the function.

                                                  ^^^^
                                                  file

Wolfgang
___________________________________________________________________________________
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] 5+ messages in thread

end of thread, other threads:[~2013-02-04 19:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-04 18:11 What is changed? H. van der Meer
2013-02-04 18:13 ` Aditya Mahajan
2013-02-04 18:26   ` Meer H. van der
2013-02-04 19:12     ` Wolfgang Schuster
2013-02-04 19:13       ` Wolfgang Schuster

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