Form Event Initialize Error

When a file launches, the Initialize ends by opening a form. The form has several embedded variables that show values pulled from other files that are set as Auxiliary files.

With Initialize previously ending with a ShowVariables to display those values, they continued to show as not existing. (their un-intialized values). I found that by adding a procedure to the Form Event, the variables could be updated and it worked perfectly. Voila!

But it only works when the file is launched before the Auxiliary files are opened. If this one file is closed then re-opened with the Auxiliary files having been left open, I get an Initialize error: “parameter( function: Current procedure was not called as a subroutine.”

The error comes up whether I have the Form Event call a procedure or simply enter ShowVariables X,Y,Z…

It’s also independent of whether the file is shared or not.

Is there some way to get this to work? FWIW, I’ve tried a few error handling techniques but they all get the error too.

Panorama’s code that calls the .Initialize routine is available for your examination. Here’s the code.

As you can see, if an .Initialize Error appears, that is caused by an error in your .Initialize code. This message has nothing to do with your Form Event code. The Form Event code is entirely separate from the .Initialize code, and doesn’t run until later.

Since you haven’t shared any of the code with us, I’m left stumbling about in the dark to some extent. But I’m guessing that though you have moved some code from the .Initialize procedure to the Form Event code, there is still some code left in the .Initialize procedure, and that is the source of the error.

It makes sense that changing the Form Event code doesn’t have any effect, because that is not where the error is occurring.

It’s a slightly complex initialize procedure but as noted, it runs fine with no errors aside from ending with variables failing to display their initialized values. THAT is the issue I was trying to resolve by adding code to the Form Event. Code that is as simple as a ShowVariables command

The error ceases entirely, 100%, if I remove that code from the Form Event. The error does not occur with ShowVariables in the Form Event if the files and the Auxiliary files are all being launched.

With the Auliiary files already open, the Initialize error occurs if the Form Event has the ShowVariables. It does not occur if there is no Form Event.

It doesn’t strike me as being an error in the Initialize procedure since the Form Event toggles the error on or off, and only under the specific circumstances of Auxiliary files being already opened or not.

My objective remains the same though. I need variables to show their values when the file is opened. Some of those values are pulled from the Auxiliary files.

I’ve even resorted to having one almost blank form open during the entire Initialize process, then opening the desired form at the very end of the Initialize.

When it all comes to a stop and the form is sitting there with the variable errors displaying, all it takes is a ShowVariables to make them all just right. So they clearly have their values assigned, but are simply failing to display them.

Ending the Initialize with the ShowVariables doesn’t do it. That was when I decided to pursue another means, such as the Form Event.

(ShowVariables is followed by the names of the variables, of course.)

I’m not going to be able to debug a complex problem with no code, probably wouldn’t be able to debug it without the databases in question on my computer. The symptoms you describe make no sense to me.

That said, I have an alternate suggestion for you. First of all, I would suggest adding catcherror("", to the formula in the object (Text Display, etc.). That way you’ll never seen an error. I do this all the time now, in fact, in a future version I’m planning to add a checkbox that will do this for you.

Secondly, I would suggest adding this code at the end of your .Initialize procedure, and leave the Form Event code empty.

wait 0
setactivedatabase "Original Database"
showvariables ...

When the .Initialize code runs, it’s too soon to display the variables. Using the wait statement will cause the remaining code to run later, after Panorama has finished the entire “open” process. Note that this isn’t about a time delay, but about not running the code until the next cycle of the “run loop” happens.

I believe the setactivedatabase statement is needed because most likely some other database might be active at that point, though I’m not sure about that, perhaps that line can be left out.

After many, many launches and careful observation I’ve concluded that the file opens and runs its Initialize procedure, then it opens the Auxiliary databases, and then returns to the file and form I’m working with. That’s why Form Event would draw it without error on a launch of all files though I don’t know why it would fail on a later launch.

By adding open file processes to the Initialize instead of relying on Auxiliary file status, I’ve resolved the issue.

I’m glad it’s resolved, but that’s very mysterious. As you can see in the code above, Panorama literally calls the .Initialize code, then immediately opens the auxiliary databases. Hmm, one possible clue – the last thing the openauxiliary statement does is use the topdatawindow statement to bring the original database back to the front. If you’re not using the auxiliary feature, that isn’t happening.