.InitializeFunctions error before custom statement is registered

I have several custom functions and hotkeys defined inside the .InitializeFunctions procedure in my Custom Library. Everything has been working great.

I recently defined a new hotkey which triggers a Custom Statement from the same custom library. This is generating an error message when opening panorama.

The .InitializeFunctions procedure is running before the statement is registered. The result is the hotkey not being defined, but the custom statement being registered successfully. If I then manually open the custom library, the hotkey is defined as expected. Has anyone else encountered this situation?

Is it a solution having a Custom Library that registers Custom Statements first and then a second one running the .InitializeFunctions procedure?

Just speculation here, but you might want to have your hotkey do a FarCall to the custom statement, rather than using the custom statement itself. Something like

FarCall "Hugo Alvarez's Custom Statements", "MYSTATEMENT", param

rather than

MyStatement param

Excellent Dave, that worked like a charm!
Thanks!

Dave’s solution is a good immediate workaround. There are other workarounds I can think of, but since you already have one working I won’t bother.

The .InitializeFunctions procedure is intended for a specific purpose. It wasn’t intended as a general place for running code you want run when Panorama launches. However, I can see that it would be nice to have a place where hot keys are defined, so for the next version I have added a new .InitializeHotKeys procedure. If you add this to a Custom Library database, Panorama will call it after all of the functions and statements are registered. So once b27 is out you won’t need to use Dave’s workaround any more, just put the definehotkey statements in this procedure instead of in .InitializeFunctions.