[metapost] how to get the size of an array
taco at elvenkind.com
Wed Aug 1 17:03:25 CEST 2007
Manuel Yguel wrote:
> I have two questions:
> 1) suppose I have an array defined like that
> numeric range;
> rang:=3; ...
> how can I now the size of this array ?
You can't, unless you maintain a separate counter yourself. Metapost
does not actually have arrays, it has structured variables instead.
The syntax with brackets is a perhaps little misleading; it is shorthand
for "any numeric expression". For instance, you can skip integers, and
use negative, and even fractional values.
> 2) is there equivalent of fopen, fscanf functions in metapost to read
> through a file ?
No, there is nothing like that. Preprocessing the input by using a
scripting language is the usual way of dealing with this issue.
More information about the metapost