Hi, This one is a challenge for me but I am sure it's a breeze for the more experienced Palm developers out there.
Got a database full of tests as per below: ----------------------------------------------------------------------- typedef struct { long test_id; long sort_id; char name[1]; // might be longer but is null-terminated } PackedTest; typedef struct { long test_id; long sort_id; char *name; // might be longer but is null-terminated char *status; char *exec_time; char *exec_date; } Test; ---------------------------------------------------------------------- User works on the Palm, presses a button and I need to update the execution date and time. Hence the following routine: ---------------------------------------------------------------------- static void UpdateTestTimeDate() { Handle TestRecHandle; Test *TestRec_write; UInt32 curr_time_in_secs; DateTimePtr curr_time_date; char curr_date[10], curr_time[10]; // call PalmOs system function for getting number of secs since midnight Jan 1st 1904!!! curr_time_in_secs=TimGetSeconds(); // convert into date/time structure TimSecondsToDateTime (curr_time_in_secs, curr_time_date); // copy relevant fields: time and date StrPrintF(curr_time, "%02d:%02d:%02d", curr_time_date->hour, curr_time_date->minute, curr_time_date->second); StrPrintF(curr_date, "%02d/%02d/%02d", curr_time_date->month, curr_time_date->day, (curr_time_date->year)%1000); TestRecHandle = DmGetRecord(TestDB, CurrentTestRecord); UnpackTest( TestRec_write, MemHandleLock(TestRecHandle)); TestRec_write->exec_date = curr_date; TestRec_write->exec_time = curr_time; // *1 MemHandleUnlock(TestRecHandle); PackTest(TestRec_write, TestRecHandle); DmReleaseRecord(TestDB, CurrentTestRecord, true); } ---------------------------------------------------------------------- Up to line marked *1, the record contains the right info according to CodeWarrior. I then pack the unpacked record into the database using a routine successfully used elsewhere in the program (see below). When I release the newly time/date stamped record using DmReleaseRecord, and return to access the time and date fields, they are empty. ANY IDEAS???? IMPORTANT: I have no direct access to this newsgroup at the moment so could you cc any replies please to [EMAIL PROTECTED] Cheers, Gary Wilson ---------------------------------------------------------------------- static void PackTest(Test *test, VoidHand testDBentry) { // figure out necessary size UInt length = 0; CharPtr s; UInt offset = 0; length = sizeof(test->test_id) + sizeof(test->sort_id) + StrLen(test->status) + StrLen(test->name) + StrLen(test->exec_time) + StrLen(test->exec_date) + 4 ; // 2 extra for 2 string terminators // resize the handle for the step record if (MemHandleResize(testDBentry, length) == 0) { // copy the fields s = MemHandleLock(testDBentry); // LOCK offset = 0; // step_id and test_id fields DmWrite(s, offset, (CharPtr) &test->test_id, sizeof(test->test_id)); offset += sizeof(test->test_id); DmWrite(s, offset, (CharPtr) &test->sort_id, sizeof(test->sort_id)); offset += sizeof(test->sort_id); // test name field DmStrCopy(s, offset, (CharPtr) test->name); offset += StrLen(test->name) + 1; // status field DmStrCopy(s, offset, (CharPtr) test->status); offset += StrLen(test->status) + 1; // exec time field DmStrCopy(s, offset, (CharPtr) test->exec_time); offset += StrLen(test->exec_time) + 1; // exec date field DmStrCopy(s, offset, (CharPtr) test->exec_date); offset += StrLen(test->exec_date) + 1; MemHandleUnlock(testDBentry); // UNLOCK } ---------------------------------------------------------------------- ******************************************************************************************************* This document is intended for, and should only be read by, those persons to whom it is addressed. Its contents are confidential and if you have received this message in error, please delete it and notify us immediately, e-mail "[EMAIL PROTECTED]". Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without our prior written consent is strictly prohibited. Any views expressed in this message are those of the individual sender, and do not necessarily represent the position of CTSL. Furthermore CTSL does not authorise or use e-mail for official contractual correspondence. Nothing received in e-mail has any contractual validity. CTSL and each legal entity in Cubic Corporation reserve the right to monitor all e-mail communications through its networks. This footnote also confirms that this email message has been checked for known computer viruses. ******************************************************************************************************* -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/