ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Refreshing (synchronizing) values between Lua variables and TeX registers
Date: Mon, 18 Jun 2012 15:02:30 +0200	[thread overview]
Message-ID: <4FDF26E6.8030407@gyza.cz> (raw)

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


\blank[big]


\stoptext

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

             reply	other threads:[~2012-06-18 13:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 13:02 Jaroslav Hajtmar [this message]
2012-06-18 14:20 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FDF26E6.8030407@gyza.cz \
    --to=hajtmar@gyza.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).