--- Mitch <[EMAIL PROTECTED]> wrote:
> The interesting thing is that when I get into the AppStop 
> routine and look at OurInfo (which is the pref structure),
> it has all the right stuff in it before the 
> PrefSetAppPreferences call.
> Then, when I restart the app and do the PrefGetAppPreferences, 
> it returns the right version number, but the prefs structure 
> is all 0's.
> ...

from AppStop:

> OurInfoSize = PreferenceAndStateTypeSize;
> PrefSetAppPreferences(ourCreatorID, ourInfoID, 
> ProgramInfo.OurVersionNum, &OurInfo, OurInfoSize, false);
> ...

from AppStart:

>  if((i = PrefGetAppPreferences(ourCreatorID, ourInfoID, 
>   &OurInfo, &OurInfoSize, false)) == noPreferenceFound){
>   OurInfo.Preferences.PlayingRightHanded = true;
>   OurInfo.Preferences.DisplayStatsCount = false;
>   OurInfo.Preferences.DefaultTees = 2;
>   OurInfo.Preferences.DefaultNumberOfPlayers = 4;
>   OurInfoSize = PreferenceAndStateTypeSize;
>   PrefSetAppPreferences(ourCreatorID, ourInfoID,
> ProgramInfo.OurVersionNum,
> &OurInfo, OurInfoSize, false);
>  }

You don't show the declaration of OurInfo.  One thing that could cause
the problem you describe (a rather obscure possibility, but I didn't
happen to see anything else, so...) would be if that structure contains
stuff in front of the Preferences which happens to be zeroes.  For
example:

typedef struct
{
  UInt16 stuff[10];
  UInt16 mostuff[20];
} OurStuffType;

typedef struct
{
  Boolean PlayingRightHanded;
  Boolean DisplayStatsCount;
  UInt16 DefaultTees;
  UInt16 DefaultNumberOfPlayers;
} OurPrefsType;

typedef struct 
{
  OurStuffType OurStuff;
  OurPrefsType Preferences;
} OurInfoType;

OurInfoType OurInfo;

In this case, if OurInfoSize is sizeof(OurPrefsType) you would be
writing the first 6 bytes of OurInfo, but the data you want to write
doesn't start until 30 bytes into the structure, so you'll actually
write whatever the first 6 bytes happen to be.

A simpler way to write out prefs is to write an entire structure.  For
example (if OurInfo actually only contains prefs info):

  PrefSetAppPreferences(ourCreatorID, ourInfoID, 
    ProgramInfo.OurVersionNum, &OurInfo, sizeof(OurInfo), false);



__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com


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

Reply via email to