Yes, but was an error in IngresaItem, now i cleanup the code and should work
logically:

void GrabaNuevoItem(void)
{
 UInt16 NuevoIndice;
 MemHandle registroH;
 OrderReg item;
 Int16 length = 0;
 Char *s;
 NuevoIndice=gNumOrden-1;

 registroH = DmGetRecord(PedidosDB, NuevoIndice);
 if(!registroH)
    FrmCustomAlert(Mensaje,"Handle null", NULL,NULL);
 else
    length = (MemHandleSize(registroH)); //Calcule last size of record

 DmReleaseRecord(PedidosDB, NuevoIndice, true); // right?

 IngresaItem(item.items);       //Load from fields to 
 item.cantitems=gcantitems;     //struct,(only item and quantity of items)
//Calcule the size of new item to add to record
 length += 16;                  //In the struct codigo size is 15
 length += sizeof(item.items[gcantitems-1].cantidad);
 length += sizeof(item.items[gcantitems-1].precio);

 registroH = DmGetRecord(PedidosDB, gNumOrden-1); //Open again, ok?
 if(!registroH)
    FrmCustomAlert(Mensaje,"Handle null", NULL,NULL);
 else
  if ((MemHandleResize(registroH, length))==0)//Resize the handle, don't problem
   {
     s=MemHandleLock(registroH);  //Lock the handle, i think don't work

     IngresaItem(item.items);     //I lost the record(�?), load again
     item.cantitems=gcantitems;
//Write the records
    DmWrite(s,offsetof(OrderReg,cantitems),&item.cantitems,sizeof(item.cantitems));
     DmWrite(s,offsetof(OrderReg,items[gcantitems-1].cantidad),
&item.items[gcantitem
s-1].cantidad,sizeof(item.items[gcantitems-1].cantidad));
     DmWrite(s,offsetof(OrderReg,items[gcantitems-1].precio),
&item.items[gcantitems-
1].precio,sizeof(item.items[gcantitems-1].precio));

     DmStrCopy(s,offsetof(OrderReg,items[gcantitems-1].codigo),
item.items[gcantitems
-1].codigo);

     MemHandleUnlock(registroH);//here error in POSE->SysFatalAlert:NULL HANDLE
    }
 DmReleaseRecord(PedidosDB, gcantitems-1, true);
//Other error: lost program counter
}

this time write the records, (i see with the RscrEdit) but i get these errors
what happend?
--
Open WebMail Project (http://openwebmail.org)

---------- Original Message -----------
From: "Albert J. Franklin" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Mon, 11 Aug 2003 20:31:23 -0400
Subject: Re: Recording problem

> Sean,
> 
>    I am puzzled by your response.  The variable len is defined in a 
> block, and then the variable length is defined in a block within the 
> scope of the block where len is defined.  By the rules of C, len 
> should still contain the value of (MemHandleSize(registroH)).  I don't 
> understand why defining length in the outer scope as you recommend 
> will cause the value of len to not be lost.
> 
> Al
> ----- Original Message -----
> From: "Sean Yang" <[EMAIL PROTECTED]>
> Newsgroups: palm-dev-forum
> To: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Sent: Monday, August 11, 2003 4:12 AM
> Subject: Re: Recording problem
> 
> > Int16 length=len ---> here is error,
> > because the "len" is a dynamic variable, not a const variable.
> > You should define the "length" at the start of function.
> > e.g:
> > Err GrabaNuevoItem(void)
> > {
> >     Int16 length;
> >    ...
> > }
> >
> > Best regards!
> >
> > Sean Yang
> > Aug.11.2003
> >
> > "rguevara" <[EMAIL PROTECTED]> ???? news:[EMAIL PROTECTED]
> > >
> > > Hello!
> > > here a new problem:
> > >
> > > Err GrabaNuevoItem(void) //Record a new item in the actual record
> > > {
> > >  UInt16 NuevoIndice;
> > >  MemHandle registroH;
> > >  Err error=0;
> > >  OrderReg item;          //It's similar to 'Sales' example struct
> > >  NuevoIndice=gNumOrden-1;
> > >  registroH = DmGetRecord(PedidosDB, NuevoIndice);
> > >  if(!registroH)
> > >     error = DmGetLastErr();
> > >  else
> > >     {
> > >      Int16 len = 0;
> > >      UInt16 Indice = gNumOrden-1;
> > >      len = (MemHandleSize(registroH));
> > >      IngresaItem(item.items);
> > >      item.cantitems=gcantitems;
> > >         {
> > >          Char *s;
> > >          Int16 length=len; //lose 'len' why?
> > >          length += StrLen(item.items[gcantitems-1].codigo)+1;
> > >          length += sizeof(item.items[gcantitems-1].cantidad);
> > >          length += sizeof(item.items[gcanti
> > >          DmResizeRecord(PedidosDB, gNumOrden-1, length);
> > >
> > >          registroH = DmGetRecord(PedidosDB, gNumOrden-1);
> > >          if(!registroH)
> > >              FrmCustomAlert(Mensaje,"Handle null", NULL,NULL);
> > >          s=MemHandleLock(registroH);
> > >
> >
> DmWite(s,offsetof(OrderReg,cantitems),&item.cantitems,
> sizeof(item.cantitems)
> > );
> > >
> >
>
DmWrite(s,offsetof(OrderReg,items[gcantitems-1].cantidad),&item.items->canti
> > dad,sizeof(item.items->cantidad));
> > >
> >
> DmWrite(s,offsetof(OrderReg,items[gcantitems-1].precio),&item.items-
> >precio,
> > sizeof(item.items->precio));
> > >
> >
>
DmStrCopy(s,offsetof(OrderReg,items[gcantitems-1].codigo),item.items[gcantit
> > ems-1].codigo);
> > >         }
> > >      DmReleaseRecord(PedidosDB, Indice, true);
> > >     }
> > >  return error;
> > > }
> > >
> > > Allways say Handle null, the index it's all right.
> > > if delete the second DmGetRecord the handle point to nobody location
> > > Please helpme!
> > >
> > >
> > >
> > >
> >
> >
> >
> > --
> > For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palmos.com/dev/support/forums/
> >
> 
> --
> For information on using the Palm Developer Forums, or to unsubscribe, 
> please see http://www.palmos.com/dev/support/forums/
------- End of Original Message -------


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to