ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* working on page refs with MP
@ 2021-03-18 17:14 Werner Hennrich
  2021-03-18 18:55 ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Werner Hennrich @ 2021-03-18 17:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2513 bytes --]

Hello everyone,

I'm having page references and want to calc / draw 'Page x of y' for
some subsections in MP.
How can I pass 'em down so I end up with numbers to do calculations with?

    \setuplayout[header=15mm]
    \def\myHeader[#1]#2{
    \ignorespaces
    \getdummyparameters[ref=,next=,#1]
    \pagebreak[yes]
    \pagereference[\dummyparameter{ref}]
    \doassign[header][first=\dummyparameter{ref}]
    \doassign[header][next=\dummyparameter{next}]
    {\tfc\bf{#2}}\par
    \vskip3mm
    }
    \def\fillWithText[#1]{
    \dorecurse{#1}{
    \input tufte
    \input knuth
    }
    }
    \setupheadertexts[\setups{page:header}]%
    \startsetups page:header
    \setupMPvariables[hdrPgs]
    [curr=\pagenumber,
    first={\ref[page][\headerfirst]},
    next={\ref[page][\headernext]}]
    \framed[
    frame=off,
    background={hdrPgs}
    ]{}% all to be done in MP
    \stopsetups
    \defineoverlay[hdrPgs][\useMPgraphic{hdrPgs}]
    \startuseMPgraphic{hdrPgs}
    StartPage; % calc and draw 'Page x of y'....
    numeric numCurr; numCurr := \MPvar{curr};
    string strFirst; strFirst := "\MPvar{first}";
    string strNext; strNext := "\MPvar{next}";
    message("=======================");
    message("MP_hdrPageNrs: curr="& tostring numCurr & ", sFirst="&
    strFirst & ", sNext="& strNext);
    % fails:
    numeric numFirst; numFirst := \MPvar{first};
    StopPage;
    \stopuseMPgraphic
    \starttext
    \myHeader[ref=a,next=b]{AAAA aaaa AaAaAaAa}
    \fillWithText[10]
    \myHeader[ref=b,next=c]{BBBB bbbb BbBbBbBbBb}
    \fillWithText[3]
    \myHeader[ref=c,next=d]{CCCC ccccc CcCcCcCc}
    \fillWithText[8]
    \myHeader[ref=c,next=last]{DDDD ddddd DdDdDdDdDd}
    \fillWithText[8]
    \pagebreak[yes]
    \pagereference[last]
    This is the last page, goodby
    \stoptext

metapost        > message : MP_hdrPageNrs: curr=1, sFirst=\ref
[page][a], sNext=\ref [page][b]
metafun         > log >
metafun         > log > error: Improper subscript has been replaced by zero
metapost        > log > <*> ... numeric numFirst; numFirst := \ref [page]
metafun         > log >
metafun         > log > A bracketed subscript must have a known numeric
value;

So MP gets the macro and tries array access... I tried \expanded,
\numeric, and resolving the page numbers via \ref[page][id] at the
various code levels - unsuccessfully so far - and out of wit now.

TIA, Werner



[-- Attachment #1.2: Type: text/html, Size: 6100 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-19 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 17:14 working on page refs with MP Werner Hennrich
2021-03-18 18:55 ` Hans Hagen
2021-03-19 10:56   ` Werner Hennrich

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