If you are never going to do anything with the HH data on the PC then replacing the record is a reasonable option. If you can see that one day you may want to access and modify the data on PC via conduit and PC application then replacing is not a good option because it can be a problem to sync HH and PC changes. If you go the replace route make sure that you remove the old record instead of deleting it cause DmDeleteRecord leaves the records header entry for use by a conduit.
To modify the record as per your in-memory example closely follow the example you posted (unless I don't understand the question). 1. get the handle to record x 2. create a OemiDBRecordType structure pointer to the record using the handle (OemiDBRecordType* recPtr). You will have to decide the char* or fixed array size issue for FileName as mentioned by Henk. Allocating fixed size record storage is the no brainer solution (no record packing an unpacking required) and it is fine if you won't have a lot of records otherwise you go variable length record and get the record pointer via an unpack function. The addressbook and/or the memopad sample apps have examples using variable length records with packing and unpacking the record data. 3. Write the data. Assuming fixed size records: UInt8 newFreq = 50; /* Vehicle.CH[4].EQ._30Hz = newFreq; */ OemiDBRecordType* offsetPtr = 0; // simple way to get a structure member offset DmWrite(recPtr, &offsetPtr->CH[4].EQ._30Hz , &newFreq, sizeof(newFreq)); 4. unlock the record pointer 5. release the record - Ralph "Tony Janke" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I am trying to store a data structure in a record and have a few questions. There seems to be (at least) 2 ways to store data in a record. You can either create a new record, and over write an old record with the new copy that contains the new field values. The other way is to edit the individual fields that were changed. I'd think it would be much more efficient to modify only the necessary fields and that brings me to my first question. The example documentation uses a simple struct: typedef struct { char FirstName[20]; char LastName[20]; char PhoneNum[20]; } DBRecord; typedef DBRecord DBRecordType; typedef DBRecord* DBRecordPtr; then when a field (say Last Name) is changed, a simple: (MemHandle) h = DmGetRecord(gDatabase, index); if (h) { // could fail due to out of memory! DBRecordType * p = (DBRecordType *) MemHandleLock(h); // write only the changed fields of record instead of the whole record Err err = DmWrite(p, OffsetOf(DBRecordType, LastName), "Knopp", 20); MemPtrUnlock(p); DmReleaseRecord(gDatabase, index, true); will replace the old last name with the new one. My structure is as follows: typedef struct{ UInt8 _30Hz; UInt8 _60Hz; UInt8 _120Hz; UInt8 _250Hz; UInt8 _500Hz; UInt8 _1000Hz; UInt8 _2000Hz; UInt8 _4000Hz; UInt8 _8000Hz; UInt8 _16000Hz; } EQFreq; typedef UInt8 FilterType; enum FilterType{HighPass, LowPass, ByPass}; typedef UInt8 MixerType; enum MixerType{NONE, A, AB, AC, ABC, B, BC, C}; typedef UInt8 StereoModeType; enum StereoModeType{LEFT, RIGHT, STEREO}; typedef Char* FileName; typedef struct{ Boolean STEREO; // Stereo Linked? EQFreq EQ; // 10-band EQ settings MixerType MIXER; // Mixer controls FilterType FILTER; // Filter type (HP/LP/BP) UInt8 VOLUMELEVEL; // Volume Level UInt16 FILTERFREQ; // Filter Fc UInt8 DELAY; // Delay in 100's of uS Boolean MUTE; // Is Muted? T/F Boolean SOLO; // Is SOLO? T/F } ChannelAtt; typedef struct{ Char* FileName; ChannelAtt CH[6]; // Channel 0 used for Tune Mode StereoModeType StereoMode; // Channel mode, Left, Right or Stereo Link } OemiDBRecordType; To modify the 30Hz filter value for say channel 4, I would normally do a: OemiDBRecordType Vehicle; UInt8 newFreq = 50; Vehicle.CH[4].EQ._30Hz = newFreq; Currently, I have a global variable (Vehicle) that I can access in any function, but I wanna change that and store the data in records. How would I change that value using the DmWrite function? my goal is to use each record as a "file" so that the user can select between different setups by choosing different records. Also, while trying to troubleshoot my code, I am using the simulator to look at my Database and record data. I can see the database and the records I create, but I don't know how to decipher the data I see in that record. When I assign a value to a variable and write that value to the record, I see that some of the record values change but don't know how to interpret those changes to verify they are correct. How do read these values and is there a way to see a database and record during debugging? thanks in advance! ~Tony -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/