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/

Reply via email to