> I am having a hard time understanding the restrictions on access to global
> variables in the PalmOS environment.  The various documents I have read
> state that global variables are not available for certain launch codes.
> Does this mean the variables themselves are not accessible, or have they
> merely not been initialized?

Typically on the Palm, global variables are stored in a region on the heap
which is pointed to by the A5 register.  In a launch situation where you
don't have global access, the A5 register is already is use storing the
global pointer for the active application.  This region that A5 points to
also has some system data, so changing it to point to a "local" global pool
for the sublaunched program would affect system stability.

> Can I initialize them?  Since the event
> handling architecture in PalmOS does not allow for including call data in
> event handlers, it is pretty difficult to get around using global
variables.

The usual method is to use features, which can be used like globals --
allocate dynamic space for a structure with all your "global" data, then
store the pointer in a feature which you can retrieve using an API call in
any subroutines which need them.

--
Ben Combee
Veriprise Wireless <http://www.veriprise.com>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to