I would start off by cleaning your first if like this:
 if ((CurrentCliente != noRecordSelected ) && 
      (DmNumRecords(ClientesDB) > 0 ) &&
     (CurrentCliente != 0 ))
     myCliHandle = DmGetRecord(ClientesDB,CurrentCliente);
 else
     myCliHandle     = DmNewRecord (ClientesDB, &index,
sizeof(sClients));
  

Next I would start popping out form alerts until I found where I was
dying!

Luiz Fernando Barbosa wrote:
> 
> Hello,
> I'm new in Palm Programming. I am having some trouble in the code below . it
> returns me "Fatal exception" and i couldn't find the error.
> Here's my code,
> 
> static Boolean ClientesSaveData()
> {
> 
> VoidHand myCliHandle = NULL;
> sClients *ClientePtr;
> FormPtr  frm;
> FieldPtr field;
> UInt     offset=0;
> UInt     index=0;
> 
> if (CurrentCliente != noRecordSelected && DmNumRecords(ClientesDB) > 0 &&
>   CurrentCliente != 0 )
>          myCliHandle = DmGetRecord(ClientesDB,CurrentCliente);
> else
>   {
>    myCliHandle     = DmNewRecord (ClientesDB, &index, sizeof(sClients));
>   }
> 
> frm = FrmGetActiveForm();
> 
> if (myCliHandle)
> {
>   ClientePtr = (sClients *) MemHandleLock(myCliHandle);
>   offset = 0;
> 
>   field = (FieldPtr) FrmGetObjectPtr(frm, FrmGetObjectIndex(frm,
> ClientesEditCGCField));
>   field->text[StrLen(field->text)+1] = '\0';
>   DmWrite (ClientePtr , offset, field->text, StrLen (field->text) + 1);
>   offset += StrLen(field->text)+1 ;
> 
>   field = (FieldPtr) FrmGetObjectPtr(frm, FrmGetObjectIndex(frm,
> ClientesEditRazaoField));
>   field->text[StrLen(field->text)+1] = '\0';
>   DmWrite (ClientePtr , offset, field->text, StrLen (field->text) + 1);
> 
>   MemHandleUnlock (myCliHandle);
>   DmReleaseRecord (ClientesDB, index, true);
>   CurrentCliente = 0;
>   return true;
> }
> }
> 
> any help ?
> 
> Thanks,
> 
> Luiz Fernando

Reply via email to