On Mon, Jul 19, 2010 at 10:09 PM, Wolfgang Schuster <schuster.wolfgang@googlemail.com> wrote:

why don't you use then a ctx file which process first the document and then MyAnalyze...

yes I know.
The point is: while the *first mode  is clear and can be managed inside context,
the concept of last run is problematic.
If one wants to be sure that "this tex code will be parsed only at the last run"
then the tex code must be enclose inside a \startmode[LAST]\stopmode 
and processed with 
#>context mydoc.tex && context --mode=LAST mydoc.tex
(let's forget of errors for the moment)
But   if the tex code modify  mydoc  then the first context mydoc is superfluous.
So in the end the tex code must do nothing of relevant, and hence  it can be replaced by an external program MyAnalyze
which in general must have as input the input source mydoc.tex, the output file mydoc.pdf and the log mydoc.log
and processed with
#>context --batch mydocument.tex ; MyAnalyze mydoc.tex mydoc.pdf mydoc.log
to take care of errors.

--
luigi