Hi -
So I still can't see the problem!!
In this loop (follows), I assign memory for voltagetxt, and create a record,
locking it down. I then write a zero at the beginning of the record, so that
the string written in the record will be null-terminated.
The function runs up until the DmStrCopy() call in the for() loop, where I
get a DmWriteCheck failed error.
??
I believe I created the record with the correct size (enough for samples
copies of voltagetxt, as well as samples copies of the ',' character (hence
the 1), and the length of the recordname string, to be appended after the
loop. I also believe I'm passing correct values to the DmStrCopy() function.
(This time!)
If anyone could help (Jim?) I would be a very happy man.
Mike.

else if (event->eType == firstUserEvent)
        {

          voltagetxt = MemPtrNew(sizeof(Char [5]));
          record = DmNewRecord(PalmoscopeDB, &index,
(samples*StrLen(voltagetxt))+1+(StrLen(&recordname[0])));
          //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, index, &zero, StrLen(&zero));
          index += StrLen(&zero);

          //check for fatal error
          ErrFatalDisplayIf(error, "Could not write to new record.");

          currentfrm = FrmGetActiveForm();//returns a pointer to the current form
          voltageindex = FrmGetObjectIndex(currentfrm,
Palmoscope_runValue_fldField);


          for(i =0; i<=samples; i++)


            if(running)


              voltage = SysRandom(0);//SysBatteryInfo(false, NULL, NULL, NULL,
NULL, NULL, NULL);
            StrIToA(voltagetxt, voltage);
            //write voltagetxt into record
            error = DmStrCopy(recordp, index, voltagetxt);
            ErrFatalDisplayIf(error, "Record not big enough or voltagetxt
too long");
            //error = DmWrite(recordp, index ,voltagetxt,
StrLen(voltagetxt));
            index += StrLen(voltagetxt)+StrLen(&zero);
            ErrFatalDisplayIf(error, "Cannot write to record");
              //redraw field
              FldSetTextPtr(FrmGetObjectPtr(FrmGetActiveForm(), voltageindex),
voltagetxt);
              FldDrawField(FrmGetObjectPtr(currentfrm, voltageindex));
              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, 0, true);
          //global pointer to the current record
          CurrentRecord = 0;
          running = false;
          FrmReturnToForm(0);
          FrmSetActiveForm(CurrentView);
          handled = true;
        }


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to