Source procedure: code in Before Opening Files and the other file embeds is never reached

Applies to: the ABC chain, a Source procedure; the poster wrote "ABC 6.1" and posted in the Clarion 6 group.

Problem

A new Source procedure had two tables in Other Files, with Generate Open/Close and Save/Restore ticked. Code placed in the Before Opening Files, Before Closing Files, Before Saving Files and Before Restoring Files embeds was never hit when the procedure ran.

Solution

  1. A Source procedure runs only the code you write. The generated code holds routines for the file handling that the ticked boxes request, such as OpenFiles and SaveFiles.
  2. Call those routines yourself where you need them, for example DO OpenFiles and DO SaveFiles at the start of your code.
  3. If you want the file handling done for you, use a Window procedure instead of Source, without actually showing a window; one poster did this when he needed the table functionality.

Caveats

  • The poster concluded the embeds on a Source procedure cannot be used the way they are in a Window procedure.
  • He then tried the Window procedure route, putting code at priority 8000 in the Window Manager Init embed after the files open, and issuing RETURN LEVEL:Benign. Calling that procedure from a test button never returned, and the thread ended with no answer for that.

Today (2026)

Not re-tested. This is how the generated Source procedure was described, and the Window procedure hang was never explained, so check it on a current build before relying on that route.

Sources: Tobias R. (Mar 2022, the question), Jeff S., Sean H. (Mar 2022) in softvelocity.public.clarion6.