> From: adam davies
>
> //Constants that define the 1st database record
> #define DB_ID_START 0
> #define DB_ID_SIZE (sizeof(ULong))
> #define DB_ITEM_START (DB_ID_START + DB_ID_SIZE)
> #define DB_ITEM_SIZE 2
> #define DB_QUANT_START (DB_ITEM_START + DB_ITEM_SIZE)
> #define DB_QUANT_SIZE 2
> #define DB_RECORD_SIZE (DB_QUANT_START +
> DB_QUANT_SIZE)
>
What are the DB_ITEM and DB_QUANT that you think take 2 bytes each?
You should post the code you use to write a db record.
the 2 can be ignored, that is an example from something else, they are set
to 16
I did use nuRecords and numRecords1 for the second DB
/////////////////////////////////////////////////////////////
This is for one of the DB's, not to sure how to implement the second, this
works o.k
if(((error=DmCreateDatabase(0,"ResDB-T018", 'T018',
'pos',false))!=dmErrAlreadyExists)&&(error!=0))
{
FrmAlert(DBCreationErrorAlert);
return(0);
}
if(ResDB==NULL)
{
ResDB=DmOpenDatabaseByTypeCreator('pos', 'T018',dmModeReadWrite);
}
else
upStack = true;
numRecords=DmNumRecords(ResDB);
cursor=0;
if( numRecords == 0 )
{
newRecord1();
FrmGotoForm( ListForm );
}
// We are going to a particular record
if( cmd == sysAppLaunchCmdGoTo )
{
// In case our app was running before the find
FrmCloseAllForms();
// Point the cursor to the found item
cursor = ((GoToParamsPtr)params)->recordNum;
// Go to the details page
FrmGotoForm( ListForm );
// If we are running on top of ourselves,
// return to the original event loop
if( upStack )
{
upStack = false;
return( 0 );
}
}
else
// Display log from
FrmGotoForm( LogForm );
/////////////////////////////////////////////////////////////
the first newRecord()
static void newRecord( void )
{
VoidPtr precord; // Pointer to the record
// Create the database record and get a handle to it
hrecord = DmNewRecord( OrderDB, &cursor, DB_RECORD_SIZE );
// Lock down the record to modify it
precord = MemHandleLock( hrecord );
// Clear the record
DmSet( precord, 0, DB_RECORD_SIZE, 0 );
// Unlock the record
MemHandleUnlock( hrecord );
// Clear the busy bit and set the dirty bit
DmReleaseRecord( OrderDB, cursor, true );
// Increment the total record count
numRecords++;
// Set the dirty bit
isDirty = true;
// We're done
return;
}
/////////////////////////////////////////////////////////////
second newRecord()
////////////////////////////////////////////////////////////////////////////////////
// This function creates and initializes a new record
static void newRecord1( void )
{
VoidPtr precord; // Pointer to the record
UInt recAttrs; // The record's attributes
// Create the database record and get a handle to it
if( (hrecord = DmNewRecord( ResDB, &cursor,
DB1_RECORD_SIZE )) == NULL )
errorExit( MemoryErrorAlert );
// Lock down the record to modify it
precord = MemHandleLock( hrecord );
// Clear the record
DmSet( precord, 0, DB1_RECORD_SIZE, 0 );
// Initialize the date and time
MemSet( &dateTime, sizeof( dateTime ), 0 );
dateTime.year = NO_DATE;
dateTime.hour = NO_TIME;
DmWrite( precord, DB1_DATE_TIME_START, &dateTime,
sizeof( DateTimeType ) );
// Unlock the record
MemHandleUnlock( hrecord );
// Clear the busy bit and set the dirty bit
DmReleaseRecord(ResDB,cursor , true );
// Increment the total record count
numRecords++;
// Set the dirty bit
isDirty = true;
// Get the record attribute bits
DmRecordInfo( ResDB,cursor , &recAttrs, NULL, NULL );
// Clear the category bits
recAttrs &= ~dmRecAttrCategoryMask;
// Set the category to the appropriate category
if( listCat == dmAllCategories )
recAttrs |= dmUnfiledCategory;
else
recAttrs |= listCat;
// Set the record attributes
DmSetRecordInfo( ResDB, cursor, &recAttrs,
NULL );
// We're done
return;
}
______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/