Hi everyone:
I'm writing an application that collects data from the serial port and
creates a CSV list. My problem is this:
I use the loop at the end of this message to write the value into the
record. It seems to go OK but looking at the database (using a database
viewer during hotsync), it contains nonsense. If this loop is not the
correct way of doing things, can anyone suggest a way of writing the values
and commas into the record?
Thanks v.much,
Mike.
...
<code>
else if (event->eType == firstUserEvent)
{
//create new record
//size of samples*voltage (for the values), samples*sizeof(Char) (for the
commas) + other text.
record = DmNewRecord(PalmoscopeDB, &index,
(samples*sizeof(voltage)+samples*sizeof(Char)timeStringLength+dateStringLeng
th));
//lock down the block containing the new record
recordp = MemHandleLock(record);
//write a zero to the first byte of the record to null terminate the new
record string
error = DmWrite(recordp, 0, &zero, sizeof(Char));
//check for fatal error
ErrFatalDisplayIf(error, "Could not write to new record.");
currentfrm = FrmGetActiveForm();
voltageindex = FrmGetObjectIndex(currentfrm,
Palmoscope_runValue_fldField);
for(i =0; i<=samples; i++)
if(running)//flag set elsewhere
voltage = SysRandom(0);
StrIToA(voltagetxt, voltage);
//write voltagetxt into record
DmWrite(recordp, i*sizeof(voltage),&voltagetxt,
sizeof(voltage)/8);
//redraw field - displays new value on screen
FldSetTextPtr(FrmGetObjectPtr(FrmGetActiveForm(), voltageindex),
voltagetxt);
FldDrawField(FrmGetObjectPtr(currentfrm, voltageindex));
//SysTaskDelay(100*(samples/lengthno));
EvtGetEvent(&newevent, (100*(100*lengthno)/(100*samples)));
if(newevent.eType == ctlSelectEvent)//quit button has been pressed
{
running = false;
}
}
}
// Unlock the block of the new record.
MemPtrUnlock(recordp);
// Release the record to the database manager. The true value indicates
that
// the record contains "dirty" data. Release Record will set the
record's
// dirty flag and update the database modification count.
DmReleaseRecord(PalmoscopeDB, index, true);
//global pointer to the current record
CurrentRecord = 0;
running = false;
FrmReturnToForm(0);
FrmSetActiveForm(CurrentView);
handled = true;
}
<code>
...
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html