I really wish you would have tried this suggestion I made a few days ago. Based on some tests I just did, I think it would eliminate all of the problems in your code. Basically, if you close a database and then immediately open it again, the open doesn’t work.
This may be difficult or impossible to fix. The closefile and closedatabase statements work by telling Apple’s code to close the document. I believe the Apple code does this asynchronously, in other words, the Apple code returns control to Panorama immediately but the “close” operation continues in the background. For other asynchronous operations like saving and printing, Apple provides a mechanism to notify the original program when the task is finished. When running Panorama code, this notification mechanism allows Panorama to stop and wait for the task to finish before proceeding to the next statement. But there is no such notification mechanism for close. Apple seems to assume that they can take whatever amount of time they want in the background, and normally they would be correct.
For the tiny database I was using, I found that the problem went away if I used a wait 1
after the close operation. A delay of 0 wouldn’t work. But I think there is absolutely no assurance that 1 is enough for any database, it probably isn’t. I don’t think there is any way to know what a sufficient time is. I do not recommend putting wait statements after your close statements.
What does the doctor say when you tell him “it hurts when I do that”? He says don’t do that! You haven’t explicitly told us that you are closing a database and then turning around and opening it again, but you are doing that, right? I think the best solution is to not do that. At the start of your task, open the databases you need. Leave them all open until the task is complete. If for some reason you don’t want the windows visible, use makesecret. But don’t close them until the end.