ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \restorecounter ignores first save
@ 2016-08-27 13:41 Wolfgang Schuster
  2016-08-28 15:16 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfgang Schuster @ 2016-08-27 13:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Hans,

the save/restore state for the counter in the example is ignored.

%%%% begin example
\enabletrackers[structures.counters]

\definecounter[test]

\starttext

\incrementcounter[test]
\convertedcounter[test]

\dorecurse{10}
   {\savecounter[test]
    \incrementcounter[test]
    \convertedcounter[test]
    \restorecounter[test]
    \par}

\stoptext
%%%% end example


The problem is the check for the table size in the counters.restore 
function because after the first save the size of the table is 1:

function counters.restore(name)
     local cd = counterdata[name]
     if not cd then
         report_counters("invalid restore, no counter %a",name)
         return
     end
     local saved = cd.saved
     if not saved then
         -- is ok
     elseif #saved > 1 then
         cd.data = remove(saved)
     else
         report_counters("restore without save for counter %a",name)
     end
end



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

end of thread, other threads:[~2016-08-28 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-27 13:41 \restorecounter ignores first save Wolfgang Schuster
2016-08-28 15:16 ` Hans Hagen

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