Error in .Initialize procedure is not flagged

If, in a .Initialize procedure, I have a statement like alpha = "" and there is no variable or field called alpha, the .Initialize procedure stops at that statement without giving an error message, so I’m not aware that the procedure has failed to complete. Is this supposed to happen? Can somebody replicate this?

Yes, I get the same behavior. (behaviour if you prefer).

I don’t know if this is any help but I declare the variable in the the Global line and then I initialize the variable. I have found that you are better off going through the 2 steps in .Initialize. For instance:
Global Hello,Goodbye,Seeya
«Hello»=""
«Goodbye»=""
«Seeya»=""

Agreed. I find it a good practice to always initialize variables when they’re created. I’m now using PanX’s style to do it since it’s nice and clean.

LetGlobal gvAlpha = ""
Let lvBeta = ""
LetFileGlobal fgGamma = "SomeValue"
etc

That said, if I try to use an undeclared variable as Michael did, my good practice is irrelevant.

Some times in my .Initialize procedure I forget to take advantage of the makefileglobals statement. This is probably the easiest way to create and assign values to a whole bunch of fileglobals. It also make it extremely easy to keep adding additional fileglobal variables to my .Initialize procedure as I develop the database.

Thanks for the lots of interesting advice on techniques but the elephant in the room is the fact that Panorama X runs a .Initialize procedure, finds an error and stops with no warning, so the user assumes that the procedure has run as planned. This is not good. Can it be fixed?

In Panorama X the .Initialize procedure is run on a slight delay, using the same mechanism that is used by the starttimer statement. Code run by the timer mechanism does not display a modal alert when an error occurs, because this could wind up essentially locking up Panorama by displaying the same alert over and over again as the timer keeps running. Instead, a notification of the error is displayed. Michael, in the past you’ve mentioned that you have turned off notifications on your system, so you won’t see the error message. I strongly recommend allowing Panorama to display notifications – there are a number of instances where Panorama X uses a notification, and only a notification, to let you know about something occurring.

Of course the other possibility is to bake in whatever error handing you want into your code using try catch.

try
    regular
    initialization
    code
    here
catch
    display error message
endcatch

You can learn more about using this technique to catch errors here:

Thanks Jim - the try statement does the job so I’ll just add it into each .Initialize as I encounter them. A bit of work but way better than being constantly badgered by unwanted notifications.