ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: hajtmar@gyza.cz, mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Refreshing (synchronizing) values between Lua variables and TeX registers
Date: Mon, 18 Jun 2012 16:20:01 +0200	[thread overview]
Message-ID: <4FDF3911.9080702@wxs.nl> (raw)
In-Reply-To: <4FDF26E6.8030407@gyza.cz>

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


-- 

-----------------------------------------------------------------
                                           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 : 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 14:20 UTC|newest]

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

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=4FDF3911.9080702@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=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).