I have generated a .pdb file
(using pdbc compiler
http://www.obermuhlner.com/public/Projects/Palm/PDBC/index.html )
with the records as follow:

record
begin
     includebin "abc.txt"
end;

The file structure of the binary text file is like this:

(minX)(minY)(noOfCoordinate)(x1)(y1)(x2)(y2)......(noOfCoordinate)(x1)(y1)(x
2)(y2)......(0)
where  minX, minY  are  double values (8bytes)
           noOfCoordinate, x, y  are  short values(2bytes)
           0  is used to indicated the end

noOfCoordinate is used to define how many x, y pairs follow
eg, if noOfCoordinate = 3 then there are 3 groups of x, y values,
i.e. (noOfCoordinate)(x1)(y1)(x2)(y2)(x3)(y3)

the problem is in every record, the number of the group
[(noOfCoordinate)(x1)(y1)(x2)(y2)......] is different, and I make a typedef
struct as follow:

typedef struct {
        double   minX;
        double   minY;
        Int16     noOfCoordinate;
        Int16     *arrayX;
        Int16     *arrayY;
} Path;


I try to get the values in the record using the codes below
but I cannot get the values in the record, I have spend quite a lot of time
but I still don't know where is the problem, can anyone tell me how to get
the values in the record? thx!

static readFunction()
{
     Path                path;
     MemHandle    recordH;
     UInt16            i = 0;

     recordH = DmQueryRecord(gDB, 0);    //Read the 1st record

     // Try to get the values in the record
     gMinX = path.minX;
     gMinY = path.minY;
     numCoord = path.noOfCoordinate;

     while (numCoord != 0) {

           for (i=0; i<numCoord; i++) {
               arrX[i] = path.arrayX[i];
               arrY[i] = path.arrayY[i];
          } //End of for loop

          numCoord = path.noOfCoordinate;

     } // End of while loop

     MemHandleUnlock(recordH);

}



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

Reply via email to