[metapost] string-array

Hartmut Henkel hartmut_henkel at gmx.de
Mon Dec 20 00:00:40 CET 2004


On Sun, 19 Dec 2004, stefan knorr wrote:

> dear listies,
> i plan to store some strings as array in the form:
>
> ----------------------------------------------
> |numeric a[];
> |string  b[];
> |a[0] = 0; b[0] := "label1";
> |a[1] = 3; b[1] := "label2";
> |.
> |.
> |.
> ----------------------------------------------
>
> later i want to use the structure to draw labels in the form:
>
> ----------------------------------------------
> |label.rt(btex b[0] etex, (a[0], a[0]));
> ----------------------------------------------
>
> this does not work.
> how can i do something like this? any suggestions?
> is there any atlernative way to do something like this?

Try TEX.mp, it's part of the metapost bundle:

% file foo.mp
input TEX;

beginfig(1)

numeric a[];
string  b[];
a[0] = 0; b[0] := "label1";
a[1] = 3; b[1] := "label2";

label.rt(TEX(b[0]), (a[0], a[0]));

endfig;
end

Then type mptopdf foo.mp. Interestingly, only acroread displays the
foo-1.pdf file, showing the "label1" string, while xpdf seems to hang,
mysteriously. Is it only here on my i686 woody PC?

Regards, Hartmut



More information about the metapost mailing list