>I don't see a cooresponding DmRead type function.  What is
>the best way to read one variable at a time from a DB record?


You don't need a DmRead.  DmWrite exists solely to protect the storage
heaps from errant writes.  There's no way to corrupt your storage heap when
reading from it.  So just lock the record and go get your data:


#define Var1Size      (sizeof(Int))
#define Var2Size      (sizeof(Int))
#define String1Size   (StrLen(String1Ptr(p)) + 1)
#define String2Size   (StrLen(String2Ptr(p)) + 1)


#define Var1Offset    (0)
#define Var2Offset    (Var1Offset + Var1Size)
#define String1Offset (Var2Offset + Var2Size)
#define String2Offset (String1Offset + String1Size)


#define Var1Ptr(p)    (((char*) (p)) + Var1Offset)
#define Var2Ptr(p)    (((char*) (p)) + Var2Offset)
#define String1Ptr(p) (((char*) (p)) + String1Offset)
#define String2Ptr(p) (((char*)((char*) (p)) + String2Offset)


VoidHand  recH = DmGetRecord ( database, index )
char*          recP = MemHandleLock ( recH );

var1 = *(Int*) Var1Ptr(recP);
var2 = *(Int*) Var2Ptr(recP);
StrCpy (string1, String1Ptr(recP));
StrCpy (string2, String2Ptr(recP));


-- Keith Rollin
-- Palm OS Emulator engineer






"Mike Davis" <[EMAIL PROTECTED]> on 05/17/99 01:46:22 AM

Please respond to [EMAIL PROTECTED]

Sent by:  "Mike Davis" <[EMAIL PROTECTED]>


To:   [EMAIL PROTECTED]
cc:    (Keith Rollin/HQ/3Com)
Subject:  Re: DmWrite Function question




Thanks,
One more question.  I used to use MemMove for fixed length
structures, to copy from Database to structure.  I now use
DmWrite and write each variable one at a time since I no
longer have a fixed length structure.
I don't see a cooresponding DmRead type function.  What is
the best way to read one variable at a time from a DB record?
Say I have variables that are:
Int  var1;
Int  var2;
char String1[Max];  // actual string length varies
char String2[Max];    // actual string length varies
and my record is: var1, var2, String1, String2  (where the
actual string length for 1 and 2 varies.
What is the best way to read this data into their cooresponding
variables?
This was so much easier with fixed length records, but I don't want
to waste memory and would like to only write significant data.
Thanks


Reply via email to