Hi!
I am quite tired thinking about this problem since it made my head burn..
Well, I would like to add an appointment to the datebook database.
Therefore I have to convert between my application structure and
the built-in structure and call ApptNewRecord (whis is part of DateDB.c)
Here is my problem:
As you see, I'm passing the address of appRecord to the function
TransformVeran...
There I convert between the two formats and then..
if I called ApptNewRecord from within this function it works great.
If I called it from within my mainfunction (that calls this
TransformVeran..) it
adds a record to the datebook (even with the correct description) but the
date
is sth. weired.. just a random date.. :-((
Any ideas?
// Ok, first of all my mainfunction:
// #######################
[...]
ApptDBRecordType appRecord, *appRecordP;
MemHandle appRecordH;
[...]
appRecordH = MemHandleNew(sizeof(appRecord));
appRecordP = (ApptDBRecordPtr) MemHandleLock(appRecordH);
appRecord = *appRecordP;
err = TransformVeranstaltungToApptDBRecord(veranstaltungP, &appRecord,
true, &recordNewInAppNum);
// if I do the following the wrong date is added.
err = ApptNewRecord(gDatebookDB, &appRecord, &recordNewInAppNum);
// Now the function that converts the structures and can call ApptNewRecord
successfully..
// ####################################################################
Err TransformVeranstaltungToApptDBRecord(Veranstaltung *veranstaltungP,
ApptDBRecordType *appRecordP, Boolean saveAsNewRecord, UInt16 *recordNumP)
{
Err err = errNone;
ApptDateTimeType when;
char* txtP;
when.startTime.hours = veranstaltungP->date.hour;
when.startTime.minutes = veranstaltungP->date.minute;
[...] and so on...
appRecordP->when = &when;
appRecordP->description = txtP;
appRecordP->alarm = NULL;
appRecordP->repeat = NULL;
appRecordP->exceptions = NULL;
appRecordP->note = NULL;
// So here the call to ApptNewRecord adds a correct appointmen..
ApptNewRecord(gDatebookDB, appRecordP, recordNumP);
}
But I would like to call it from within the mainfunction and just have a
function that
converts between these two formats..
I don't know where the mistake can be since I'm passing just the address to
the
convert-function, doing my stuff there and then when I would like to pass
this
address to ApptNewRecord (from within the mainfunction) it doesn't add the
correct date?
Many thanks for any ideas about this topic!!
Dyk
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/