Code after Post(Event:CloseWindow) in an embed point still runs before the window closes

Applies to: an ABC-generated window procedure with hand-written embed code (the thread uses ThisWindow.SetResponse); the thread was posted in the softvelocity.products.c55ee group and names no version.

Problem

The poster ran conversion steps in an embed point. When a step set an error code she used Post(Event:CloseWindow) to leave, but the statements after it in the same embed (the next conversion steps) still ran, and only then did the window close. A Return Level:Fatal right after the post stopped it, and she asked whether that was the proper way.

Solution

Post(Event) only queues the event. The window handles it the next time the procedure reaches ACCEPT, so the rest of the embed code runs first. The thread gave these ways to stop it:

  1. Leave the embed right after the post with a RETURN, usually RETURN Level:Benign or Level:Notify. The procedure ends, the accept loop cycles and picks up the queued EVENT:CLOSEWINDOW.
  2. Put the code that must not run on the other side of the IF, so it only runs when there was no error.
  3. Call ThisWindow.SetResponse(RequestCancelled) instead of the post. It posts EVENT:CLOSEWINDOW and also sets GlobalResponse in one step. Apart from that the thread saw little difference between the two.
Do ConvertDesc
if GLO:ErrorCode
  ThisWindow.SetResponse(RequestCancelled)
  Return Level:Notify
end
Do ConvertDept

Caveats

  • The poster confirmed this shape with the answerer and said she would retrofit her code; she did not report a run.
  • Code that sits in the CLOSEWINDOW event itself can be guarded with a test on the error code.
  • On update forms the thread mentions further trouble with PROP:AcceptAll and a changed record buffer, and does not detail it.

Today (2026)

The queued-event behaviour is part of how the accept loop works, so this likely still holds. Not re-tested on a current build.

Sources: Lisa D. (Mar 2001, the question and follow-ups), Juanro, John G., Jim K., Jon W. (Mar 2001) in softvelocity.products.c55ee.