Hi Andy,
            I think this Sample code will serve your purpose,Since I am
carrying out the same stuff.

typedef struct
 {
    char name[1];
 } PackedCustomer;

typedef struct
 {
    char *name;
 } Customer;

// The code after user interface.

        if(OK Button Pressed)


         strBookmarkfldText = FldGetTextPtr(BookmarkfldPtr);
//         DmCloseDatabase(gCustomerDB);
         InitializeBookmarks(strBookmarkfldText);
               StrIToA(strBookmarkfldText,Curr);    // I am accepting number
from the user
         InitializeBookmarks(strBookmarkfldText);
        }


static void InitializeBookmarks(CharPtr strContent)
{
 Bookmark b1;   // = {"Try for the Best & be prepared for the worst"};

 Bookmark *bookmarkDB[1];


OpenOrCreateDB(&gBookmarkDB,kBookmarkDBType,kSalesCreator,mode,0,kBookmarkDB
Name,&created);
 b1.Content = strContent;

 bookmarkDB[0] = &b1;

 for(i = 0;i<1;i++)
 {
  UInt index = dmMaxRecordIndex;

  VoidHand h= DmNewRecord(gBookmarkDB,&index,StrLen(strContent) + 1);

  if(h)
  {
   PackBookmark(bookmarkDB[i],h);
   DmReleaseRecord(gBookmarkDB,index,true);
  }
 }
 DmCloseDatabase(gBookmarkDB);
}
static void PackBookmark(Bookmark *bookmark,VoidHand bookmarkDBEntry)
{
 UInt length = 0;
 CharPtr s;
 UInt offset = 0;

 length = StrLen(bookmark->Content) + 1;

 if(MemHandleResize(bookmarkDBEntry,length) == 0){
 s = MemHandleLock(bookmarkDBEntry);
 offset = 0;
 DmStrCopy(s,offset,(CharPtr) bookmark->Content);
 MemHandleUnlock(bookmarkDBEntry);
 }
}


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

Reply via email to