Closedatabase statement doesn't stop file being secret


#1

I have a procedure which, at its kernel, has this code snippet which I’ve copied to a new file which has nothing else in it:

opensecret "Delta"
setactivedatabase "Delta"

; Do lots of stuff in 'Delta'

; Now I want to make 'Delta' visible for data entry by the user

closedatabase "Delta"
openfile "Delta"

; But the file doesn't appear because:

message info("windowname") 

gives this response:

File%20still%20secret

I hope that’s self-explanatory. BUT, when I create another new file and paste the code in again, the file ‘Delta’ is not secret.

I’ve put the offending file here:

https://www.dropbox.com/s/myfx3x7t0l0f06n/Testing%20secret%20files.zip?dl=0

And I’d be grateful if somebody could test it and see what result they get - open ‘Alpha’ and run ‘CopyTest’.


#2

I think you may have found a bug (I didn’t try it), but Panorama X has a documented way to perform what you want to do – the opensavedwindows statment. I would recommend that you use that instead of the closedatabase openfile statements.


#3

Thanks Jim, I’ll try that.


#4

No, that didn’t help. The file doesn’t become visible and the message info("windowname") statement still shows the file as being secret.

When you have a moment to spare, see if the files I sent tell you anything.


#5

Every Panorama database has a list of windows that were open the last time it was saved. It uses that list to determine what windows to open when the file is opened. If the database is open, you can see this list by using

dbinfo("savedwindows","databasename")

Somehow your Delta database got saved with no windows open. So this list is empty, and Panorama doesn’t open any windows when the file is opened. And that’s your problem.

I opened Delta secretly, then used the Memory Usage window to open the data sheet. Then I saved the database. After I did that, everything worked. My suggestion of opensavedwindows worked, and your original code worked also.


#6

I did get an empty result from the dbinfo( function.

I then opened Delta conventionally and tried again and got the result, “DATASHEET”, so all appeared to be well.

Now all I have to do is work out how to achieve that result in the middle of a six-page procedure. I don’t think that will be easy. If the equivalent of the Delta database in my big procedure (the one from which I extracted the original snippet above) is somehow being saved with no windows open, it’s happening every time I run the procedure but I can’t fathom how that could possibly happen?


#7

And, coming back to the Alpha/Delta files, if I open ‘Alpha’ and run ‘CopyTest’, close Alpha and close Delta, Panorama X quits unexpectedly.

Alternatively, if I open ‘Alpha’ and run ‘CopyTest’ and close Delta, Panorama X quits unexpectedly.

And sometimes, doing these things, Panorama X just freezes and I have to force quit.

Can you replicate any of these behaviours?


#8

This seems to work perfectly:

opensecret "Delta"
setactivedatabase "Delta"

[Do lots of stuff in 'Delta']

openfile "Delta"

Is there any reason why it shouldn’t?


#9

Try changing the question from “how,” to “when” or “where.” Sprinkle the following code line through your procedure,

if arraycontains(info("files","Delta",cr()) nsnotify "1"+dbinfo("savedwindows", "Delta") endif

changing “1” to “2” etc with each subsequent uses. Run your procedure then look through the notifications to see when/where the list of “saved windows” turns empty.

The if statement prevents errors by not checking dbinfo( when Delta isn’t open. Similar testing code could be crafted with message, alertsheet, etc. statements, but would require user action to resume the procedure. With your search narrowed you’ll probably spot the problem. Knowing precisely where a procedure “freezes” or “quits unexpectedly” doesn’t always explain “why” in my experience, but probably will explain “why” here. My guess is you are saving Delta while it is Secret and thus saving it as no windows.


#10

That’s exactly what i’ve been doing John! Good catch.

My last post was incorrect - it was a test on the wrong data. But this does work - Delta is open for business:

opensecret "Delta"
setactivedatabase "Delta"

delta = "entry"
save
setactivedatabase "Delta"
opensheet

where ‘delta’ is a field in the Delta database.