Page 1 of 1

PostPosted: Mon Feb 12, 2007 5:32 pm
by haines
i think i am missing something in the documentation for this function. I can write to preferences fine but when I try to read the pref, it returns -2 though i have exactly the same cid and index #. Here's my code. Can you help me?

saveFilePref(){
int i;
char fileNameArray[15];

i=0;
while(fileName@[i]!= '\0'){
fileNameArray[i] = fileName @[i];
i++;
}
fileNameArray[i] = '\0';
AppPrefBytes(i,cid, 1, &vers, 1, &fileNameArray);
}

readFilePref(){
int i, indx;
char fileNameArray[15];

indx = AppPrefBytes( -1, cid, 1, 0, 1, &fileNameArray);
if(indx!= -2){
i=0;
while (fileNameArray[i] != '\0'){
fileName @[i] = fileNameArray[i];
i++;
}
fileName@[i]='\0';
}
}

PostPosted: Mon Feb 12, 2007 11:15 pm
by jstadolnik
First make sure that first AppPrefBytes call succeeds (returns a non-negative value).

Second, your "i" variable is one too small to include writing the null character when AppPrefBytes does the write. Though, this shouldn't have any effect to whether the preference entry gets created.

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Thu Feb 15, 2007 3:20 am
by haines
I have not been able to find the reason for AppPrefBytes returning a -2. I checked and the first AppPrefBytes returns a zero. Looking at it in RsrcEdit, it looks OK. I decided to create a new file and use the db functions. It would be interesting to see what I'm doing wrong. It does it with POSE as well as on my Sony PEG TJ37.

PostPosted: Fri Feb 16, 2007 1:41 am
by jstadolnik
The code behind the AppPrefBytes function is very simple, and it looks correct to me.

What version of the library and PocketC are you using (the most current version available is can be found here: http://pocketc.net/forum/topic.asp?TOPIC_ID=3183). (Note that the library doesn't support PocketC Architect, and I no longer support the library anyhow.)

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm