A new problem with the `closefile` statement

This code:

local alpha
alpha = "info"
OpenSecret "Checkbook"
Window "Checkbook:Secret"
D = alpha

results in the error message, “Field or variable D does not exist”. Placing a save or message statement between the last two lines fixes it. Oddly, a nop statement doesn’t. This is possibly related to the issue at Problems Opening and Closing a Database

In case people are wondering why I’d write such a bizarre code snippet, I should explain that there was originally a truck-load of other code in and around this lot - I’ve just thinned it down to what causes the problem.

If I put

message «Pay To»

after the CloseFile, the message is “Kinko’s” (the value in the Pay To field in the current Checkbook record.) It looks like the file isn’t closing immediately.

I’ve always found it to be a good habit to activate the file or window that I do want to be working with, even after closing a file, even when it should be safe to assume that the right window becomes active.

If the secret window didn’t close, the simple extra step of activating the desired window makes the difference.

Should that be a BitBucket report?