On 18-6-2012 15:02, Jaroslav Hajtmar wrote:
Hello ConTeXist and Lua experts

Is there any way to refresh values ​​between the values ​​stored in Lua
code and TeX registers?
I need to evaluating the values of TeX registers (counters, dimensions,
height of boxes, etc.) during the Lua cycle.
I would like in the cycle ​​read values from the TeX registers and write
back there so that all values ​​were always synchronized.
Or I need advice on how to proceed. Most of my Lua code is in a separate
file in Lua
function.

Is there a universal way to "jump out of cycle" to TeX synchronize all
values ​​between TeX registers and Lua values (even at the cost of
slowing down) and then go back into the cycle and continue?

I do not write cycles using the TeX macro language, but so far I'm
failing in way around it.
What I need to I knowing or What I need to learn?

Thanx Jaroslav Hajtmar


The minimal example shows (maybe) what I mean:

\newcount\testcount

\def\countrefresh{\directlua{tex.count.testcount = tex.count.testcount +
1}}

\def\universalrefreshcommand{\directlua{-- ???}}

\def\printdebuginfo{
\directlua{tex.sprint(': ',tex.count.testcount, " - ",
"\\the\\testcount","\\par")}
}

\starttext


Here values are not synchronized:

\testcount=0
\startluacode
local i=0
for i=1,5 do
tex.sprint(i)
tex.count.testcount = tex.count.testcount + 1
tex.sprint("\\printdebuginfo")
end
\stopluacode


\blank[big]

Here values of textcounter are synchronized:

\testcount=0
\startluacode
local i=0
for i=1,5 do
tex.sprint(i)
tex.sprint("\\countrefresh")
tex.sprint("\\printdebuginfo")
end
\stopluacode


\blank[big]


Is there a universal way to "jump out of cycle" to TeX synchronize all
values ​​between TeX registers and Lua values (even at the cost of
slowing down) and then go back into the cycle and continue?


\testcount=0
\startluacode
local i=0
for i=1,5 do
tex.sprint(i)
tex.count.testcount = tex.count.testcount + 1
tex.sprint("\\universalrefreshcommand")
tex.sprint("\\printdebuginfo")
end
\stopluacode

sure, as the 'prints' end up in the input buffer and are dealt with after the lua code has been dealt with; at some point we can have coroutines for going back and forth

in your case I'm not sure what is the problem as you can set the valus at the lua end and print the current value when needed


\blank[big]


\stoptext

___________________________________________________________________________________

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

maillist : [email protected] /
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
___________________________________________________________________________________


--

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------


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

maillist : [email protected] / 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
___________________________________________________________________________________

Reply via email to