I have an NDSolve problem that needs a list of a large number of events that are generated programmatically. Here is a simple example that demonstrates the problem on Mathematica 7 and 8 (the versions I have access to):
NDSolve[
{y''[t] == 10, y[0] == 0, y'[0] == 0},
{y},
{t, 0, 1},
Method -> {"EventLocator",
"Event" :> {y[t] - 2, y[t] - 1},
"EventAction" :>(*{Throw[Print["i=",1],"StopIntegration"],Throw[
Print["i=",2],"StopIntegration"]}*)
Table[Throw[Print["i=", i], "StopIntegration"], {i, 3}]
}
];
The code as it is does not work (the second event should be triggered first, and it prints i=1), but if I use the commented block in EventAction, it does work, and prints i=2.
What is the right syntax to make this work? Thanks for any help!