OpenSecret can't find a file


#1

I have other OpenSecrets that seem to work fine, but this one won’t

OpenSecret "UpdateControl"

gets this response at the bottom of the procedure window: ‘Database “UpdateControl.pandb” does not exist.’

Funny thing, a file with exactly that name exists in the database folder, and if I Open it from Pan X before running this procedure it works with it just fine. This line is one of many like it in a large .Initialize procedure, each of which is intended to open files that are not already open. It’s not doing anything prior to this that might have set the default folder to something else. It’s not even the first file in the procedure that is opened secret (all successfully).


#2

I’ll bet that is the key. Even though you think you aren’t, you are doing something along the way that is changing what Panorama thinks is the current folder.


#3

That’s what puzzles me. I don’t do any folder manipulation in any code, I just open files and depend on Pan looking in the same place each time, because they all live in the same place. What kind of command would change the current folder? Is there an info( parameter that would report which folder is considered “current”? I see a bunch of folder variations available, but not for this that I can find.


#4

Although it is not documented for this exact usage, I found that using message folder("") returned the current folder path. I then used message dbinfo("folder","") which returned the same path except the later had a trailing “/” at the end which the former did not…


#5

Gary’s answer is correct, but also…

The current folder is whatever folder the current database is in. There is no way to change the current folder other than to open a different database or to Save As the current database to a different folder.


#6

I have a consistent response to an action I have taken about this, and I’ll leave it to smarter people to explain it. I do no saving of databases to other folders in this procedure (or any others), so there is no reason to think the file can’t be found because the default folder has changed.

I put message folder("") in my code just before the lines that try to open this particular database “secret”. It shows the correct folder, as I expected, but when I click OK to move on, it happily opens this file and continues to the end of the procedure. I tried using nsnotify folder("") instead and while it also reports the correct folder, the file isn’t opened and the procedure stops. Then I tried just a line of code instead (in the same place) to see if just referencing the function will trigger success:

local zz zz=folder("")

but it doesn’t work either. Then I tried the next obvious thing - a message command that has nothing to do with the folder() function, not invoking the function at all, and it lets the procedure complete after I click on it. It would seem that somehow the “message” command, or responding to it, modifies the environment enough that Pan can now find the file.

I would be happy to try other things you might suggest to demystify this


#7

My guess is that this is some kind of timing problem that might be solved using a short delay before the problem opensecret statement.

local startTime
startTime=now()
loop
   nop
until now()>startTime+1

If this is not enough of a delay you can increase it a second at a time just to see it that is the problem.


#8

One thing you’ve never done on this thread is to post your entire procedure. It’s possible that something might “jump out” for one of us if we could see all the code.


#9

That sounded like a good idea, but Panorama keeps throwing me curves. First I decided to create a procedure “Delay” that takes a parameter incr which would be the delay in seconds (or whatever the “+1” in your example is) so I could feed it various delay amounts to see what works. I even made a “DelayTest” procedure that would prompt me for the delay just to see how my new procedure responded. It worked fine. So I added “call Delay, 1” to my procedure just before the attempt to open secret the file in question. “Call statement failed, procedure Delay does not exist.” That makes no sense, but Pan not being able to find something that is really there is sounding like a familiar refrain. This continues after restarting Pan.

So I embedded the full code Gary provided. Value of 1 does nothing, nor does 10. I tried 100 and it seemed to work, but not in a satisfactory way. I have about 12 nsnotify lines in my procedure to let me know its progress. I see 4 of them before it hits the file it can’t open, then no more. When I add some delay, all of the delay happens before the procedure starts executing. I watch the beachball spin after I press Run, then finally the parade of notifications starts, from the beginning. When the delay was 100, as I said, it seemed to finally open my file, but I wasn’t able to duplicate it. And a delay like that is entirely unacceptable, and I don’t think it’s addressing the actual problem.

We need a bigger drawing board.