Hello folks, I've read in many places that when an application is launched with a launch code different from sysAppLaunchCmdNormalLaunch, sysAppLaunchCmdGoTo or sysAppLaunchCmdURLParams, it is not allowed to use global variables. The same goes when the application is responding to a notification it has registered to receive.
I presume this means not just that the global variables are not initialized - but that they are in portion of memory which is not accessible to the application and that the application will crash if it tries to access (read or write) that portion of memory. Correct? Also, the documentation says that access to the static variables is similarly unavailable. Now, how do you get around this limitation? My application needs to start not only when the user explicitly launches it but also when some other events occur - some of which result in special launch code and others result in notifications. While the application is working, it needs to display some user interface - forms, buttons, alerts, etc. I use global variables to pass information from the handler of one form to another. For instance, one form shows a list of items. When the user taps on some item, another form pops up, showing additional information about the element of the list that has been tapped on. The information which element this is, is kept in a global variable. Similarly, I use static variables a lot - mostly, to pass information from one event to another in a form's event handler. I use just a few global variables and, I guess, could get rid of them if I try real hard - but I don't see how to get rid of the static variables. Things are a bit easier when handling notifications - from what I've read, you can pass to the notification handler a chunk of memory where you can put the "global" variables you want it to see. I haven't actually tried to do this, but I have a reasonably good idea how it is done. But what about the special launch codes? I've been able to think of the following workarounds: 1) Store each global or static variable in a feature. What is limit on the size of feature memory an application could use? My global and static variables are all plain (i.e., no structures or arrays) - but there are quite a few of them, especially the static ones. 2) Store all global and static variables in a chunk in the Unsaved Preferences database and load them from there. 3) Re-launch my application via SysUIAppSwitch (or SysAppLaunch?) from its code that responds to special launch codes, passing it a custom launch code, so that it knows what it has to do, once started. Would that work? Are there any better ways to solve this problem? For various reasons, I don't want to set an alarm, so that my application can be notified later; I need to do the processing as soon as the special launch code is received. Regards, Vesselin -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
