At 01:36 PM 5/4/99 -0700, you wrote:
>Hi all,
>
>Bare with me I'm new to this event stuff.
>
>I can't figure out where to build and initialize my data structures so
>that they remain available only when a user is in a particular form. I
>know I could make them *Global* , but as we all know this is not good!
>:)
>

Heh, go on, point out the one thing no-one around here mentions ;]

This problem is endemic to the whole "event-driven" world, and it stems
from the interface not being owned by your application.  In the Palm
paradigm, an application is basically just a glorified collection of
scripts, and the only thing holding it together is global memory.

There are various thing you can do to reduce the global nature of your
application, but these are basically "point of reference" methods - you
could put your info in a Database (yes, just another global, but even worse
- other applications can get at it).  You could have just one global, which
does reduce the problem but does not eliminate it.  You could try and
subclass the FormType for all your forms, but I suspect that you would be
asking for trouble.  And really useful method of solving your "global"
problem is to ignore it.

There are a few other more complicated methods of avoiding the problem, but
they are mostly just that - ways of avoiding it, not solutions.  A true
solution requires that each form holds the data it needs, but it seems Palm
has not offered any easy way of doing this, such as a "VoidPtr UserData" in
FormType.

I may not be correct about subclassing - I've never tried, but if you
wanted to, you could do something like this:

typedef struct MyForm {
  FormType      super;
  Blah          blah;
} MyForm, * MyFormPtr;

The only problem is then getting the OS to use it instead of the normal
FormType.

Reply via email to