Works with Openfile (sorta) but not with opensecret


#1

Using Yosemite
Pan 10.10.5

The following code works (when used in a standalone procedure)
[gvCreditMaster is correctly defined folder path]

OpenFile gvCreditMaster+"CCMASTERFILE.pandb"
window "CCMASTERFILE:Secret"
message info(“windowname”)
selectall
removeallsummaries
select «ApprovCode»="02213C"
message info(“selected”)
stop

The message info(“window name”) gives me CCMASTERFILE as expected since there is no Secret window. And it does make the correct selection, and reports back the correct selected info.
However, if I change to OpenSecret, the windowname message, when run from the standalone procedure is that of the original file not the one that was supposedly opened secret (and when I insert the code back into the procedure it originally came from, I get the name of either the procedure window or the test procedure window!). Furthermore, the CCMASTERFILE selection is not made and not reported back (apparently because it is in the wrong file).
When I try to manually open the CCMASTERFILE after trying to open it Secret, the file doesn’t open (or it is opening in a Secret Window).

I see over to the side my topic is similar to another one that suggests set activedatabase. PanX help says there’s no difference between Secret and Setactivedatabase, but this procedure was working fine before (sans messages) so I’m not sure what’s changed.
I’ll experiment with setactivedatabase. I hope I don’t have to change it everywhere.


#2

A common misconception is that a secret window is an entity, like regular windows but not visible (this misconception is my fault, as I’ll explain). However, that isn’t really true. There is no such thing as a secret window. The info(“windowname”) function will ALWAYS return the name of the topmost visible window, it will never return the name of a secret window, because there is no such thing as a secret window. All there is is an internal variable that tells Panorama to use an alternate database instead of the database that is associated with the topmost visible window. If you use the info(“databasename”) function instead, you will see that the specified “secret” database is listed.

In this case, that is because of the message statement! If you take that out, the selection will work. Here’s why – any time you do anything that changes the window configuration, Panorama clears out the internal variable that tells it to use an alternate “secret” database, and it resumes it’s normal operation of assuming that the active database is the one belonging to the topmost visible window. When the message statement is used, that opens an alert window, which is a change in window configuration. Lesson to learn – don’t use the message statement when you are using “secret” windows.


When you use a statement like:

window "CCMASTERFILE:Secret"

Panorama handles that as a special case. It is not actually creating an invisible window, rather, it just notes the word “secret” on the end, and sets the active database to CCMASTERFILE. It’s kind of a parlour trick. But as a trick, it is confusing. That’s why in Panorama X I added the setactivedatabase statement. The statement

setactivedatabase "CCMASTERFILE"

does EXACTLY the same thing as the window statement example above, but it’s up front about it, no trick. That’s why I recommend using setactivedatabase instead of window “database:secret” – both do the same thing, but * setactivedatabase is up front instead of tricky about what is really going on.


#3

My head hurts. Sometimes I think I’m too old for this stuff.


#4

That’s why I recommend forgetting about *window “database:secret”, which is tricky and makes your head hurt. There is no longer ANY reason to use this method.


#5

Ok, that makes sense, and means I have lots of changes to make.
Before I get too deep into changes, let me confirm.
I use
OpenWindowSecret "dbname"
window "dbname:Secret"
variable=info(“window name”)

frequently and it has done the job when I need to refer back to the secret database.
Now I need to change to

OpenWindowSecret "dbname"
setactivedatabase "dbname"
variable info(“databasename”)

and the variable can be used to re-access “dbname” without re-opening the file?

Also, in PanX when I open a database Secret in a procedure, I cannot open it manually afterwards. Is there something I need to add to the procedure so I can open the file manually (maybe it is opening in secret as it is the last state, even if I don’t explicitly Save)?

Thanks
Martin

Martin McCaffery
Montgomery, AL


#6

I assume you meant OpenSecret “dbname” and not OpenWindowSecret. Here is the scheme I would suggest:

opensecret "dbname" // opens the dbname database secretly
setactivedatabase "dbname" // dbname is now the active database
SecretFileVariable=info("databasename") // SecretFileVAriable now = "dbname"
setactivedatabase "" // your original database is now the active database

At this point the dbname database is still open secretly and can be accessed using the setactivedatabase statement or the forms can be opened using openform with the database option.

Using setactivedatabase to open MyForm in the dbname database:

setactivedatabase "dbname" // or use your variable for the name
openform MyForm // MyForm is now open or do some other action here

Using openform directly:

openform "MyForm","Database","dbname" // or use your variable for the db name

At this point MyForm is open and the active window and thus the dbname file is the active database. Remember that once you open a file secretly it will stay open secretly until you intentionally close it or quit Panorama. If you open a form from that secret file as shown above and then manually or procedurally close that form window it will close the file if it is the last window of that database. This explains why you think you can not reopen it manually since it is already open in secret. All of Panorama’s library files are always open secretly in the background but they are not listed in the info{“files”) list.


#7

Thanks, I’ll start working on it.

Martin McCaffery
Montgomery, AL


#8

The first two lines achieve the same thing in these two example. (As Gary mentioned, of course you need the statement is opensecret, not openwindowsecret. So there is NO difference between:

opensecret "dbname"
window "dbname:Secret"

and

opensecret "dbname"
setactivedatabase "dbname"

These two programs to the EXACT SAME THING, so there is no need to change from one to the other, though sometimes I will make this change just because I think the code will be easier to read later.

So I don’t know what this means. What kind of variable is this? I think it only makes sense as a global. If it was a fileglobal, well, you don’t need a variable, you can just use info(“databasname”). Without some idea of what you intend to do with this variable, I can’t really make sense of how it should be set up.

When a database is saved, Panorama saves the window positions. If no windows are opened, that fact will be saved, and it will open with no windows next time. You can use the Find & Open dialog to force the data sheet to open, or you can use the View Organizer wizard to open a window after it has opened secretly.


#9

Jim:

What I do usually is open a file that has a table or something I need to return to at different points in the procedure. As I was working under the assumption the Secret Window was a thing, I’ve created variables, usually local, to reach that file for the information I need, rather than writing out the name of the film and sometimes the path each time. i.e.:

OpenSecret “SomeFile”

window “SomeFile:Secret”

lvSomeVariable=info(“WindowName”)

[do stuff]

[return to calling window in a different file]

[do more stuff in original file]

window lvSomeVariable //return to the window “SomeFile:Secret”

[do stuff in SomeFile]

Sounds like maybe I’ve overcomplicated it, but it has worked for me.

Thanks

Martin

Martin McCaffery
Montgomery, AL


#10

I just did a test in Panorama 6, and this technique that you way has worked for you does not work for me in Panorama 6 (and of course doesn’t work in Panorama X). The info(“windowname”) function always returns the name of the current visible window, and never includes the words “secret”. So I don’t see how this technique could ever have worked for you, and I see no change in how the info('windowname") function works between Panorama 6 and X.


#11

I’ll have to dig up an example and test it when I get back from the holidays. Maybe it doesn’t do what I thought it did, but I got the results I wanted.
Happy Holidays
Martin

Martin McCaffery
Montgomery, AL


#12

Hello Jim,

This is not true, as this screen shot shows.

The above screen shot is from the message statement

message info(“windowname”),

where the active database is a SECRET database. Whenever I use SECRET databases, I always define a variable as

w1 = info(“windowname”)

immediately upon opening the secret database. Then, as I jump around other databases during the procedure, I can always return to the correct secret database with the command:

window w1

The variable w1 most definitely has the suffix “:Secret”

This is on Pan 6. Don’t know the situation on Pan X.

Best regards,
Vic


#13

Just tested it in my Pan 6 version, and, yes, do get the :“Secret” suffix. And, calling message does not interfere with the Procedure the way it is doing in Pan X. I’ve used message frequently in debugging and never had it interfere with the window order.


#14

Ok, I figured out what was going on. I went back to Panorama 6, and still saw the same behavior as Panorama X. However, I was doing the test by clicking on the Run button in the procedure window. On a hunch, I tried running the procedure from the Action menu, and voila – I got the behavior described by Martin and Vic. So I have added this to the bug report list.