I thought I should share this event that was annoying until I figured out what I think was happening and leading my family member to ask “what’s all that cursing?” I consistently received an error message during my .Initialize procedure saying a variable did not exist, even though the variable was declared a few lines earlier. Here is the problematic code:
opensecret “TTTimekeepers”
opensecret “TTMatters”letfileglobal fgworkdate=“”
letfileglobal fgworkdateprecursor=“”
TryAgain:
letfileglobal fguserid=“”
Gettextdialog fguserid,
“Prompt”, “Please enter your ID#…”,
“Subprompt”,“”,
“Button”,“Ok”,
“Button”,“Cancel”,
“Button”,“”,
“Sheet”,“Yes”
“Width”,100,
“Height”, 24if info(“dialogtrigger”)=“Cancel”
rtn
endiffguserid=val(fguserid)
The last line is where the error occurred. I wanted to use the two secret databases in the .Initialize procedure so I opened manually instead of using the Aux database feature. I knew that the active database reverted to the calling database following an opensecret statement, so I believed when the next line was reached that the calling DB was active. But that was not the case.
Eventually I added a wait 0 statement after the second opensecret statement, and that resolved the issue.
I concluded that PanX was still opening the two databases when it reached my declaration of the variable and so the variable was created within the secret database NOT in the calling database. By the time the last statement above was reached, the active database did not match the DB where the variable had been defined. Adding the wait 0 statement ensured that the opensecret statement had completed before the next step in the procedure was executed.
Opensecret might be a statement that Jim could amend to build in this kind of protection, which I know he has done with some statements to help ensure that the code is executing in the order that you want.