Hm, I just had a look into the example source and found a strange behaviour or maybe I'm just blind...

in file AddressDB.c starting from line 1695

PrvAddrPackedDBRecord* d=0;
Int16 len;
void * srcP;
UInt8 companyFieldOffset;

flags.allBits = 0;

DmWrite(recordP, (Int32)&d->options, &s->options, sizeof(s->options));
offset = (Int32)&d->firstField;

d is a pointer to PrvAddrPackedDBRecord and is set to NULL. But as you can see, some lines later the content of d is accessed. But d is NULL, where shall d->firstField or d->options point to? Very interesting...

Srini:

Have a look into function PrvAddrDBUnpack starting at line 1759. As you can see the Address entries are just stored one after one and at the beginning, there is a number of flags which indicates, which string is present.

Henk



ScottP wrote:
As Henk suggested you're nearly there, but you can't just write out the
address record. Have a look at the Address source (from the examples) and
investigate their use of the PrvAddrDBUnpack() function in addresdb.c and
the structures it uses. What you get back from the record is a c structure,
not just text. This could explain the random characters you get when you
print it out.

This should start to point you in the right direction for how to get the
'name/firstName' fields out of a record.

What you need to do is work out the offset of the start of the 'name' field
from the start of the structure, then as Henk said, typecast that as a char*
and you can then print it out, then do something similar for 'firstName'. As
a hint, the position of 'firstName' will depend on the length of 'name', but
don't forget to account for the terminating '\0' in the strings.

Cheers, Scott


"mlv srinivas" <[EMAIL PROTECTED]> wrote in message
news:105459@palm-dev-forum...

Hi Henk,

Thanks for your advice I did the same thing how you suggested, but still I
have the problem while displaying the data on the form. The actual problem
is I'm getting some junk characters, where I'm getting the actual
count(number of records in my Address Book), please suggest me I'm new to
the PlamOS programming.
Here is my code :

Err getAddressDatabase()
{
 MemHandle mh;
 UInt16     cardNo=0;
 UInt16 recordNum;
 UInt16 index = dmMaxRecordIndex;
 short width = 0, height = 5;
 UInt16  numdatabases;
 Err err =0;
 char* pText;
 numdatabases=  DmNumDatabases(cardNo);

dbvar=   DmOpenDatabaseByTypeCreator
(addrDBType,sysFileCAddress,dmModeReadOnly);
recordNum = DmNumRecords(dbvar);
for(index=0;index<recordNum;index++)
{
 //mh = DmQueryRecord( dbvar,index );
 mh=DmGetRecord(dbvar,index);
   pText= (char*)MemHandleLock(mh);
WinDrawChars(pText,StrLen(pText),width,height);
height=height+10;
MemPtrUnlock(pText);
DmReleaseRecord( dbvar, index, true );

}

return err;
}

Thanks in Advance
Srini








_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail








--
-------------------------------------------------------------------------
[EMAIL PROTECTED]                                       www.metaviewsoft.de

<A HREF="http://www.handango.com/PlatformTopSoftware.jsp?authorId=95946";>
<IMG SRC="http://user.cs.tu-berlin.de/~jonash/werbung_palmos.jpg";></A>
-------------------------------------------------------------------------


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

Reply via email to