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
>
>
>



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

Reply via email to