Err I would need to test this to know for sure, Niemand, but from skimming over I don't think it will work as intended. For one, I think that a negative IBIS_RouteIndex signals an invalid route, so no announcement should be played then -- but that is obviously specific to the particular IBIS script. More importantly though, what would happen if you open/close the front door(s) multiple times at that same stop (because it's cold, for example)? Or when you trigger the emergency door opening valve and the door wing(s) coincidentally decide to get stuck at precisely 50% opening degree? I think it would be more robust to handle this directly via the stop brake engagement status, or rear door clearance status, while saving (in a separate variable) the fact that the announcement already got triggered once, so as to avoid unnecessary repetition unless the stop indeed has changed.
Give me an hour or two -- I'm working on a more complete example for the standard NL/NG scripts, to demonstrate how both cases (scheduled trip vs "free roam") ought to be handled.