The prof's solution looks like it should work, but have a look at this - I didn't read it very thouroughly, but it might be able to do what you want:

http://www.eyrx.com/DOC/D_GUIDE/STRTSTOP.HTM