[metapost] one question about metapost and label

liuqiang fedora.qiang at gmail.com
Mon Aug 27 08:51:32 CEST 2007


Recently, I want to draw a image with metapost. This image is about memory image of linux. 
Firstly, I want to draw one rectangular, and then I draw one line with label at the end of it.
+-----------+0xffffffff
|	    |
|	    |
+-----------+0xc0000000
|	    |
+-----------+0x0007c000
|	    |
|	    |
+-----------+0x00000000

So, I wrote this:
++++++++++++++++++++++++++++++++++++++++++++++++++
input TEX.mp
beginfig(1);
  u=1cm;
  
  def drawaddress(expr xa, ya, xb, yb, address) =
    draw (xa,ya)--(xb,yb) dashed evenly scaled 4;
    dotlabel.rt(TEX(address), (xb, yb));
  enddef;
  
  pickup pencircle scaled 1pt;
  drawoptions(withcolor red);
  draw (0,0)--(4u,0)--(4u,20u)--(0,20u)--cycle;
  
  dotlabel.rt(btex 0x0 etex, (4u,0));
  dotlabel.rt(btex 0xffffffff etex, (4u,20u));
  drawaddress(0, 1u, 4u, 1u, 0x0007c000);
  
endfig;

end
++++++++++++++++++++++++++++++++++++++++++++++++++
But, error took place:
++++++++++++++++++++++++++++++++++++++++++++++++++
[qiang at Qiang img]$ mpost temp.mp
This is MetaPost, Version 0.641 (Web2C 7.5.4)
(temp.mp (/usr/share/texmf/metapost/base/TEX.mp)
>> "btex "
>> 0
! Not implemented: (string)&(known numeric).
<to be read again> 
                   &
TEX->begingroup.write"btex "&(EXPR2)&
                                     " etex"to"mptextmp.mp";write.EOF.to"mpt...
<to be read again> 
                   ,
drawaddress->....scaled4;dotlabel.rt(TEX((EXPR4)),
                                                  ((EXPR2),(EXPR3)));
l.16   drawaddress(0, 1u, 4u, 1u, 0x00007c00)
                                             ;
? 
++++++++++++++++++++++++++++++++++++++++++++++++++
Can someone help me out of it?
++++++++++++++++++++++++++++++++++++++++++++++++++
Next, is TEX.mp
++++++++++++++++++++++++++++++++++++++++++++++++++

% This file defines TEX <string_primary> to return the picture
% resulting from running the string through tex.  It is slow,
% but more general than the standard btex..etex construction

vardef TEX primary s =
  write "btex "&s&" etex" to "mptextmp.mp";
  write EOF to "mptextmp.mp";
  scantokens "input mptextmp"
enddef;
++++++++++++++++++++++++++++++++++++++++++++++++++


More information about the metapost mailing list