ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: store counter or variable and reread again
Date: Sat, 30 Dec 2006 18:19:18 -0500 (EST)	[thread overview]
Message-ID: <alpine.WNT.0.81.0612301743060.3880@nqvgln> (raw)
In-Reply-To: <4596E9B0.8070705@wxs.nl>

On Sat, 30 Dec 2006, Hans Hagen wrote:

> Aditya Mahajan wrote:
> > On Sat, 30 Dec 2006, Peter M???nster wrote:
> >
> > 
> >> On Sat, 30 Dec 2006, Aditya Mahajan wrote:
> >>
> >> 
> >>> % Now the rest of the magic to take care of the two pass run
> >>> % Basically this says that rerun if \nofPoints != 
> >>> % \countervalue{Points}. In the next run we set \nofPoints to the
> >>> % previous value of \countervalue{Points} (the \checkPoints macro in 
> >>> % the beginning), so things should be stable after two runs.
> >>> \savetwopassdata {Points} {\nofPoints} {\countervalue{Points}}
> >>> 
> >> Hello Aditya,
> >>
> >> with the following example, I get always 2 runs:
> >>
> >> \definetwopasslist{test}
> >> \starttext
> >> bla
> >> \savetwopassdata{test}{1}{2}
> >> \stoptext
> >>
> >> Is this normal or a bug?
> >> 
> >
> > Hmm... I would have guessed that you will keep on getting infinite 
> > runs, but apparently texexec decides that two are enough. I need to 
> > look deeper to see if this is the intended behaviour. I would call it 
> > a bug, since there can be cases which need more than two runs to 
> > converge.
> >
> > 
> how about
> 
> \savecurrentvalue\SomeVar{someval}

I was just copying the way it is done with other macros \lastpage, 
etc. I will look at \savecurrentvalue also. However, something seems 
to be wrong in tex.rb

Change

def processfile
....
  while ! stoprunning && (texruns < nofruns) && ok do
....
  end
...
end

to

def processfile
....
  while ! stoprunning && (texruns < nofruns) && ok do
....
  report("stoprunning #{stoprunning}")
  report("texruns=#{texruns}, nofruns=#{nofruns}")
  report("ok=#{ok}")
  report("while=#{! stoprunning && (texruns < nofruns) && ok}")
  end
...
end

so that we can see what takes us out of the while loop.

Take Petar's test file and run it through texexec. I get

TeXExec | stoprunning true
TeXExec | texruns=2, nofruns=8
TeXExec | ok=counter.tex
TeXExec | while=counter.tex

Notice that ok=\jobname. Shouldn't ok be a boolean. And the condition 
for while is a string rather than a boolean. I am not too sure on what 
ruby does for non boolean conditionals, but the present implementation 
can break (under some crazy conditions, maybe). How about if in

def runtexutil(...)

there is a return ok in the end, for example

  begin
      logger = Logger.new('TeXUtil')
      if tu = TeXUtil::Converter.new(logger) and tu.loaded(fname) then
          ok = tu.processed && tu.saved && tu.finalized
      end
  rescue
      Kpse.runscript('texutil',fname,options)
  else
    return ok #<--------- added.
  end



Back to Peter's question, I gave a wrong explaination earlier. texexec 
just checks if the tui file has changed. If the file did not change 
from the last run, then it stops processing. So with

\savetwopassdata{test}{1}{2}

you will get two runs the first time you process the file, and a 
single run if you reprocess the file. By default, the maximum number 
of runs that you can have is 8, but you can change this by passing
--runs= to texexec


Aditya

  reply	other threads:[~2006-12-30 23:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <45941026$0$4168$ba624c82@nntp02.dk.telia.net>
2006-12-30 14:00 ` Week number Taco Hoekwater
2006-12-30 15:51   ` store counter or variable and reread again Thomas Engel
2006-12-30 16:56     ` Aditya Mahajan
2006-12-30 19:19       ` Peter Münster
2006-12-30 21:30         ` Aditya Mahajan
2006-12-30 22:35           ` Hans Hagen
2006-12-30 23:19             ` Aditya Mahajan [this message]
2006-12-30 23:51               ` Aditya Mahajan
2006-12-31  8:21                 ` Thomas Engel
2006-12-31 17:52                   ` Aditya Mahajan
2007-01-01 22:28                 ` Hans Hagen
2007-01-01  8:11               ` Peter Münster
2007-01-01 11:17                 ` Aditya Mahajan
2007-01-01 15:35                   ` Peter Münster
2007-01-01 22:14                     ` Hans Hagen
2007-01-02 18:38                       ` Peter Münster
2007-01-04 16:43                         ` Hans Hagen
2006-12-30 21:34   ` Week number Aditya Mahajan
2006-12-30 22:28     ` 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=alpine.WNT.0.81.0612301743060.3880@nqvgln \
    --to=adityam@umich.edu \
    --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).