Posttorelated without windows would be nice, some day

I discovered that posttorelated does not work if the target database does not have any open windows or data sheet. It would be nice if that were not true. I can accomplish the posting with a few lines of code without worrying about open windows in the target database, but one line would be better than five.

I’m assuming that you’re using secret windows. Since I’ll be using PosttoRelated myself and out of curiosity, I wonder if it works with all windows closed on a file set to AlwaysKeepOpen.

I’ve already found that AddRelatedRecord and SelectRelated do work in that scenario without any secret window coding.

I confess that I don’t quite understand the concept of a secret window. Is that different than the window being closed? The help page for the Window statement says

It can also open a “secret” invisible window.

Scare quotes like this can sometimes mean ‘not really’. That doesn’t quite clarify my confusion. I also found in Release note from version 10.1 (8/16/18) the statement:

If a secret window is active, the info(“windowname”) function now returns 
the secret window instead of the name of the currently visible topmost
 window. This now works the same as it did in Panorama 6

What the heck does it mean for a secret window to be active?

My situation is a database file set to AlwaysKeepOpen. I close windows frequently just to avoid window clutter, which I really dislike, so I close windows whenever they are not needed for the user.

If I make the target database secret while it has an open window, and then use posttorelated targeting that database, it still fails. (My earlier short-lived comment saying it worked was an error on my part.)

Normally, the active database is the one with the active window. It follows then, that a database must have an open window before it can be active. However, Panorama does have a means where you can make a database active, without making any of its windows active, or even open. In Panoramas 3 through 6 it was done with a statement like

Window "Database Name:Secret"

where you would use the actual name of the database you wanted to make active. That should still work in Panorama X, but in Panorama X, you can also use

SetActiveDatabase "Database Name"

Both statements do the same thing, but hopefully the new name will reduce the confusion many people had between secret windows, and secret databases.

Are you saying that you can have a window that is not visible but is designated by Panorama as the active window, i.e., a secret widow? In that case, would posttorelated might work because it thinks there is an active window in the target database even though there are no visible windows.

Sort of. A “secret” window might better be described as an imaginary window. It’s a figment of Panorama’s imagination, which Panorama also imagines is the active window. That makes its database the active database.

The operating system is responsible for drawing and managing windows, because they are drawn on the screen, which is a shared resource. The operating system knows nothing about any secret window. Panorama is managing that internally.

1 Like

That was my hope, but it appears that this hope remains unrealized :frowning:


Great explanation Dave. I like the word “imaginary” for this, you’re right, it’s a better word for what is happening.

Did you try specifying a secret window, like this:

posttorelated "database","window","database:SECRET"

I have not tried this today, but looking at the code, I think this should work.

Speaking of looking at the code, posttorelated is implemented as open source, so you can look at it yourself. The relevant code is at the bottom of the procedure.

If you specify a window, then line 150 will run. If you pass database:SECRET as the window name then it should work I think.

@CooperT Did you try this? If it worked, let me know, I’ll add it to the documentation.