hi there!
the application that i am writing is a fairly simple internal alarm
application. what i do is store the name, time and date in my own database.
saving is simple because of CRecordStream. When the alarm rings, i will have to
use back palm's api to access the database since CRecordStream has
global/static variables. no problems so far (i was able to access the
database). the problem arises when getting data from the database. i have the
following variables in the database
CString m_strName;
CDateTime m_cDate;
UInt16 m_iIndex;
DateTimeType m_cTempDate;
TimeType m_cStartTime;
Char m_chrName[100];
when i retrieve the data, the first CString is giving me a problem because it
returns an invalid pointer. and all the subsequent variables go haywire (i
could get some data, but it's not correct). how do i go around solving this?
here's a snippet of how i get the data without using CRecordStream:
void CInternalAlarmData::Load2(UInt16 p_nIndex)
{
UInt16 wCardNo = 0;
LocalID liDbID = 0;
DmOpenRef m_Database;
m_Database = DmOpenDatabaseByTypeCreator('DATA','inAl',dmModeReadWrite);
if (m_Database)
{
MemHandle recordH = DmGetRecord(m_Database,p_nIndex);
MyRecord *rec = (MyRecord *) MemHandleLock(recordH);
//m_strName = rec->tempName;
m_cDate = rec->datetime;
m_iIndex = rec->index;
m_cTempDate = rec->tempDate;
StrCopy(m_chrName,rec->tempName);
m_cStartTime = rec->StartTime;
MemHandleUnlock(recordH);
DmReleaseRecord(m_Database,p_nIndex,false);
DmCloseDatabase(m_Database);
}
else
{
CRecordStream rs((CDatabase *)&g_cInternalDB,p_nIndex);
rs >>m_strName
>>m_cDate
>>m_iIndex
>>m_cTempDate
>>m_cStartTime
>>m_chrName;
rs.Close();
}
}
using the following struct:
struct MyRecord {
CString name;
CDateTime datetime;
UInt16 index;
DateTimeType tempDate;
TimeType StartTime;
Char tempName[100];
};
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/