On 10/1/2013 2:15 PM, Marco Patzer wrote:
Hi,
I wonder if it's necessary to manually load the MetaPost variables using LoadPageState. Some of them are static and do not require an update on each page, e.g. NOfPages, but many of them might change on each page, e.g. OnOddPage, PageNumber, TextWidth. Forgetting to use LoadPageState easily results in perfectly valid code producing wrong results, which might not be hard to spot. Example:
sure, but a 'many' versus 'some' distinction is too fuzzy
\setuplayout [width=10cm] \showframe \starttext \startMPcode fill unitsquare xyscaled (\the\textwidth, 2cm); \stopMPcode
\startMPcode fill unitsquare xyscaled (TextWidth, 2cm); \stopMPcode
\startMPcode LoadPageState; fill unitsquare xyscaled (TextWidth, 2cm); \stopMPcode \stoptext
I assume it's too inefficient to load the page state automatically for each graphic. However, loading the page state automatically is simple:
Indeed. an option is to hook into setuplayout and signal changes but this is never 'quick patch' code and I don't want to be bitten by it so I need to test such hacks myself first (in real tests).
\startMPinitializations LoadPageState; \stopMPinitializations
btw, normally I do StartPage() StopPage() when I do something that relates to the page (and most of those runtime graphics don't relate to the page at all) so, more a "something i can look into" than "a quick hack" Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------