Yeah, I do the same thing, but I'm a little lazier.  I just give it file 
scope instead of function scope.  But this still declares space for N
different VoidHand's, one for each form in your app.  Having a single global
ptr seems to eliminate this problem, but breaks things as soon as I have a
second form open at the same time.  (Yes, I really am this stingy about
space on the Palm.)

The "correct" way to do this is just to have a few user bytes in the
window/form structure.

-g


----------
>From: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Re: extern globals and procedures
>Date: Wed, Oct 27, 1999, 15:45
>

>> As far as style goes, I try to keep my use of globals
> to a minimum.  I'm not
>> too fond of variables with file scope either, though.
> Sometimes, though,
>> you've just gotta.  (Hey, Palm Guys, how about four
> bytes of user storage in
>> the form structure!  Let me get rid of a lot of my
> statics, please.)
>
> In the meantime, what I do is declare a static local
> VoidHand in my form handler, and allocate memory for my
> static variables in the frmOpen case, and store its
> address in the static local VoidHand. It's almost as
> good. And if you want to conserve stack space, you can
> just throw in all the locals that would normally be
> sitting on the stack! If you compile with optimization
> turned on, the end result is that you're accessing your
> locals via an address register different from the stack
> pointer, but big deal.
>
> Of course, don't forget to free the memory when you're
> closing the form.
>
> --
> Roger Chaplin <[EMAIL PROTECTED]>

Reply via email to