My Invoices file opens my Advertisers file, and vice versa. In the .initialize procs of both files, I have an openfile statement that opens the other file. This was used in Pan 6 so that both files would be open no matter which one the user opened first. It has worked fine for years, and it was working in Pan X, until recently.
I assume that openfile (and opendatabase) will run the .initialize when the file is first opened but NOT if the file is already open. I’ve used it for years just to switch between files.
I began getting an error when the files opened up, and so far this is what happens. The code below is in the Invoices file. I started getting an error: fgItem1popup doesn’t exist when the files opened up and .initialized. But if I add in a Message statement, there is NO error, and everything works fine, after clicking the Message OK button. The variable is loaded correctly.
Also, I changed openfile to opendatabase to see if it would help, but it acts the same.
fileglobal fgItem1popup
let mainwin = info(“windowname”)
OpenDatabase “Advertisers”
OpenSecret “Price Master”
Window mainwin
message mainwin // Remove this and the error occurs in the following
What version are you using? There was a problem with some .Initialize procedures in the b27 release, this was fixed in the b28 release. I’m wondering if you might have missed the recently uploaded b28 release.
Also, FYI, you could eliminate the first line in your code and make the last line
Yes, I’m using b28 (especially since that fixed another bug I had, thank you much )
Replacing the Message statement with wait 0does fix the problem (I had tried a delay 2, but that did not fix it).
Or, replacing it with setactivedatabase “” fixes it. (Of course, the preceding window statement should have the same effect.)
I originally did have the letfileglobal as the last line, but when the error began showing up, I went back to the old method to be sure the variable was being defined in the Invoices file, before the Price Master was opened secretly. When the error was occurring, if I opened the very helpful variable view tool before opening my files, it showed that the fgItem1popup var is in the Price Master file!
It does seem to be related to intializing. If the error occurs, and I then run the .initialize proc manually, the error does not occur, and the var works as expected.