Hi alll,
    I have a struct for a PDB database on Palm handheld created by
Codewarrior like:
#define   CON_DB_TYPE    ('DATA')
#define   CON_DB_NAME       ("ConDB")
#define   CON_CREATOR_ID     ('cont')

typedef struct
{
 int     con_pk;
 int  con_incomplete;
 char    con_name [CON_NAME+1];
 char    con_company [CON_COMPANY+1];
 char con_url  [CON_URL+1];
 char    con_email [CON_EMAIL+1];
 char    con_salutation [CON_SALUTATION+1];
 char    con_title [CON_TITLE+1];
 char    con_dept [CON_DEPT+1];
 char    con_phone [CON_PHONE+1];
 char    con_address [CON_ADDRESS+1];
 char    con_city [CON_CITY+1];
 char    con_state [CON_STATE+1];
 char    con_zip  [CON_ZIP+1];
 char con_uniqueID [UNIQUEID+1];
}ConRec;
typedef ConRec* ConRecPtr;

    I created successfully this database on Palm handheld by
DmCreateDatabase()(record database).Now,I write a conduit to sync this .PDB
database.I need "convert data from HH to PC",How must do that ?
    Here I have a code for that but I doesn't run well.Anyone can show for
me about a code for that?
(I'm using Win2K,Palm Desktop4.01,CDK4.02A,VC++6.0) for writting conduit by
Palm Wizard(Palm MFC framework wizard)

long CSalesNexusMonitor::ConConvertHHtoPC(CRawRecordInfo& rInfo,void* rec)
{
 char *pBuff;
 WORD  wTemp;
 long retval = 0;
 TCHAR*  pTransBuff=NULL;
 CString csEmpty="";
 CUtils  u;

 if (!(rInfo.m_Attribs & DELETE_BIT))
 {
  pBuff = (char*)rInfo.m_pBytes;

  CConRecord *conRec=(CConRecord *)rec;
  //con_pk
  wTemp = *((WORD*)pBuff);
  wTemp = u.FlipWord(wTemp);
  conRec->con_pk=wTemp;
  pBuff += sizeof(WORD);

  //con_incomplete
  wTemp = *((WORD*)pBuff);
  wTemp = u.FlipWord(wTemp);
  conRec->con_incomplete=wTemp;
  pBuff += sizeof(WORD);

  //Allocate a buffer to hold a temp string (see below)
  pTransBuff = (TCHAR*) new char [TRANS_BUFFER_SIZE];
  if (!pTransBuff)
   retval = CONDERR_RAW_RECORD_ALLOCATE;
  memset(pTransBuff,0,TRANS_BUFFER_SIZE);

  //con_name
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_name=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_name="";
  pBuff += CON_NAME + 1;

  //con_company
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_company=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_company="";
  pBuff += CON_COMPANY + 1;

  //con_url
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_url=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_url="";
  pBuff += CON_URL + 1;

  //con_email
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_email=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_email="";
  pBuff += CON_EMAIL + 1;

  //con_salutation
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_salutation=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_salutation="";
  pBuff += CON_SALUTATION + 1;

  //con_title
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_title=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_title="";
  pBuff += CON_TITLE + 1;

  //con_dept
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_dept=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_dept="";
  pBuff += CON_DEPT + 1;

  //con_phone
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_phone=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_phone="";
  pBuff += CON_PHONE + 1;

  //con_address
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_address=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_address="";
  pBuff += CON_ADDRESS + 1;

  //con_city
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_city=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_city="";
  pBuff += CON_CITY + 1;

  //con_state
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_state=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_state="";
  pBuff += CON_STATE + 1;

  //con_zip
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_zip=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_city="";
  pBuff += CON_ZIP + 1;

  //con_uniqueID
  if ((pBuff!=NULL) && (strlen(pBuff)>0))
  {
   u.AddCRs(pTransBuff,pBuff,strlen(pBuff));
   //pTransBuff[strlen(pTransBuff)]=(char)CH_LF;
   conRec->con_uniqueID=pTransBuff;
   //pBuff += strlen(pBuff) + 1;
  }
  else
   conRec->con_uniqueID="";
  pBuff += CF_UNIQUEID + 1;

  if (pTransBuff!=NULL)
   free(pTransBuff);
 }

 return(retval);
}

class for containing data from Palm on PC Desktop:

#define   CON_RAW_REC_MEM
4+CF_UNIQUEID+CON_NAME+CON_COMPANY+CON_URL+CON_EMAIL+CON_SALUTATION+CON_TITL
E+CON_DEPT+CON_PHONE+CON_ADDRESS+CON_CITY+CON_STATE+CON_ZIP+13

class CConRecord
{
public:
 WORD       con_pk;
 WORD       con_incomplete;

 CString     con_name;
 //char  con_name[CON_NAME+1];
 CString     con_company;
 CString     con_url;
 CString     con_email;
 CString     con_salutation;
 CString     con_title;
 CString     con_dept;
 CString     con_phone;
 CString     con_address;
 CString     con_city;
  CString     con_state;
 CString     con_zip;
 CString     con_uniqueID;
public:
 CArrayEx<CMapField,CMapField>  con_flds;

 CConRecord();
 virtual ~CConRecord();

};

Thanks in advance,
Trinh.


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

Reply via email to