I am trying to learn both C and the Palm OS API and it is proving to be rather 
difficult. I have a fairly good understanding of Palm Resources and have used RsrcEdit 
quite a bit as well I have created several VB apps. What I was hoping to do was create 
a basic C application that would modify a Palm resource within the .PRC. My main 
difficulty is understanding how to load the variables and arrays into the data 
structure and once the resource is loaded in how I read the separate parts of it into 
variables.



//The structure of the resource is:

typedef struct formInfoRsrc
{
 UInt32 dbType;
 UInt32 dbCreator;
 char dbName[32];
 UInt16 useDatabase;
 UInt32 key;
 UInt16 numFields;
 fieldDesc field[1]; // this is actually the first of several fields
} formInfoRsrc;

// since field[1] is actually the first of numFields fields I need to allocate memory 
for the new resource by doing:
//  p = MemPtrNew( sizeof(formInfoRsrc) - sizeof(fieldDesc) + (numFields * 
sizeof(fieldDesc)));
// but I am not really sure how to do this as I don't know numFields until I read the 
resource.


//  The fieldDesc structure is defined as:

typedef struct fieldDesc
{
 UInt32 fieldName;
 UInt16 id;
 UInt16 type;
 char formula[100];
} fieldDesc;


//  I also know how to pull in the resources into using:

MemHandle h
formInfoRsrc *p

h = DmGetResource('data', 1000)
p = MemHandleLock(h)


---------------

My problems are:

1.  p will have the correct structure and will have all the data loaded except the 
data will only be for field[1]. I can set field[1] to field[8] or another variable in 
the declaration but I would like to be able to set it dynamically in the code. How do 
I get it p to see more than just field[1].

2.  how do I load the fieldName in p into another 4 character variable? And how do I 
select different ones associated with each field[x]?

Thanks

Greg

1


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

Reply via email to