Stephan Hennig wrote:
Thank you for the outline. For the exact mechanism of how to process an .mp file I think there are three possible cases:
1. Strictly process what's between figure(n)..endfig only.
2. Process everything up-to the specified figure, omitting stuff inside non-matching figure numbers.
3. Process everything up-to the specified figure, including all non-matching figures, but discard their output.
4. Start a new MP instance, process the whole file, save and remember the outputs (store fig.1, fig.2, fig.3 etc), then immediately close the MP instance again. The advantage is that this makes the metapost input behave exactly the same as a true external figure, something that is not possible when an already running MP instance is re-used. This is important, because the state of an already running instance can be altered in such a way that a perfectly valid metapost source suddenly fails to run. That may happen with embedded metapost code as well of course, but in that case it is much easier to correct and diagnose the problem. Best wishes, Taco