Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-07-2012
mlegnazzi mlegnazzi is offline
No confirmado
 
Registrado: ago 2006
Posts: 1
Poder: 0
mlegnazzi Va por buen camino
Error al guardar valores en un Array de TRemotable.

Hola a todos. Necesito de su ayuda. Tengo la siguiente declaración:

Código Delphi [-]
TInvoice_Body = class(TRemotable)
private
FItem_Descripcion: string;
FItem_Value: Currency;
published
property Item_Descripcion: string read FItem_Descripcion write FItem_Descripcion;
property Item_Value: Currency read FItem_Value write FItem_Value;
end;
IBodyArray = array of tInvoice_Body;
y luego..
Código Delphi [-]
TInvoice = class(TRemotable)
private
FInvoiceBody : IBodyArray;
public
published
property InvoiceBody : IBodyArray read FInvoiceBody write FInvoiceBody;
end;

Mi problema es que al asignar valores al array me da un error de memoria:

Result.InvoiceBody[0].Item_Descripcion := 'X';

Alguien me sabria decir que estoy haciendo mal. Desde ya muchas gracias.

Matias

Última edición por Casimiro Notevi fecha: 20-07-2012 a las 17:04:04. Razón: Poner etiquetas [DELPHI] ... [/DELPHI]
Responder Con Cita
  #2  
Antiguo 20-07-2012
[egostar] egostar is offline
Registrado
 
Registrado: feb 2006
Posts: 6.556
Poder: 25
egostar Va camino a la fama
Podrías mostrar el código completo de como estás asignando los valores, así no se te puede dar comentario alguno.

Saludos
Responder Con Cita
  #3  
Antiguo 20-07-2012
matiaslegnazzi matiaslegnazzi is offline
Registrado
NULL
 
Registrado: jul 2012
Posts: 6
Poder: 0
matiaslegnazzi Va por buen camino
Egostar, gracias por tu respuesta. Adjunto el codigo completo.
Es la primera vez que utilizo TRemotable y creo que mi problema es que no inicializo Items (arrayofitem). Pero ya lo intenté y no se como hacerlo.
Saludos y Gracias

Código Delphi [-]
Invoice_Body = class(TRemotable)
  private
    FItem_Descripcion: string;
    FItem_Value: Currency;
   published
    property Item_Descripcion: string read FItem_Descripcion write FItem_Descripcion;
    property Item_Value: Currency read FItem_Value write FItem_Value;

  end;
  ArrayOfItem = array of Invoice_Body;

   TInvoice = class(TRemotable)
  private
    FBranch_Code: Integer;
    FItems: ArrayOfItem;
  public
   published
    property Branch_Code: Integer read FBranch_Code write FBranch_Code;
    property Items: ArrayOfItem read FItems write FItems;
  end;

   { Invokable interfaces must derive from IInvokable }
  IwsEPS30 = interface(IInvokable)
  ['{43B60693-DBC8-4874-8267-A93FB02EAD08}']

   function WSEPS30_Invoice(ParamsStr:trParams): tInvoice; stdcall;

Luego en el código de WSEPS30_Invoice....
Código Delphi [-]
function twsEPS30.WSEPS30_Invoice(ParamsStr:trParams): tInvoice; stdcall;
var ck: widestring;
    cal: currency;
    tr_bl: OleVariant;
begin
 svr:= CoEps30Svr.create();
 result := tInvoice.Create;
 svr.LogOnEx(ParamsStr.SystemName,Paramsstr.ClientId,Paramsstr.UserName,Paramsstr.Password,Paramsstr.  AppName,ck);
 svr.PrepareByMoney(ck, Paramsstr.ClientId, Paramsstr.MeterNumber, Paramsstr.Money, 0, cal);
 tr_bl:= svr.GetInvoiceData(ck,svr.Confirm(ck));
 With Result do
 Begin
  Branch_Code := tr_bl[0][1];
  Items[0].Item_Descripcion := tr_bl[1][0][0];
  Items[0].Item_Value := tr_bl[1][0][1];
 End;
End;

Última edición por Casimiro Notevi fecha: 20-07-2012 a las 19:46:43.
Responder Con Cita
  #4  
Antiguo 20-07-2012
[egostar] egostar is offline
Registrado
 
Registrado: feb 2006
Posts: 6.556
Poder: 25
egostar Va camino a la fama
Hola matiaslegnazzi

Intenta con esto

Código Delphi [-]
function twsEPS30.WSEPS30_Invoice(ParamsStr:trParams): tInvoice; stdcall;
var 
  ck: widestring;
  cal: currency;
  tr_bl: OleVariant;
  
begin
  svr:= CoEps30Svr.create();
  result := tInvoice.Create;
  svr.LogOnEx(ParamsStr.SystemName,Paramsstr.ClientId,Paramsstr.UserName,Paramsstr.Password,Paramsstr. AppName,ck);
  svr.PrepareByMoney(ck, Paramsstr.ClientId, Paramsstr.MeterNumber, Paramsstr.Money, 0, cal);
  tr_bl:= svr.GetInvoiceData(ck,svr.Confirm(ck));
  
  //Asignamos el espacio de memoria con los registros que quieras regresar, por lo que veo es solo uno
  Setlength(result.Items,1); 
  
  With Result do
  Begin
    Branch_Code := tr_bl[0][1];
    Items[0].Item_Descripcion := tr_bl[1][0][0];
    Items[0].Item_Value := tr_bl[1][0][1];
  End;
End;

Saludos
Responder Con Cita
  #5  
Antiguo 20-07-2012
matiaslegnazzi matiaslegnazzi is offline
Registrado
NULL
 
Registrado: jul 2012
Posts: 6
Poder: 0
matiaslegnazzi Va por buen camino
Gracias Egostar. Había intentado eso pero recibo el siguiente error al compilar:

[Error] wsEPS30Impl.pas(80): Constant object cannot be passed as var parameter

Saludos.
Responder Con Cita
  #6  
Antiguo 20-07-2012
[egostar] egostar is offline
Registrado
 
Registrado: feb 2006
Posts: 6.556
Poder: 25
egostar Va camino a la fama
Ok, ¿y si cambias esto?

Código Delphi [-]
Invoice_Body = record
  Item_Descripcion: string;
  Item_Value: Currency;
end;

ArrayOfItem = array of Invoice_Body;

Lo hago de memoria, pero me parece que no necesitas hacer del Arreglo de Items una clase TRemotable, ya que está dentro de otra clase TRemotable, debe bastar con un record.

Saludos
Responder Con Cita
  #7  
Antiguo 20-07-2012
matiaslegnazzi matiaslegnazzi is offline
Registrado
NULL
 
Registrado: jul 2012
Posts: 6
Poder: 0
matiaslegnazzi Va por buen camino
Hice la modificacion, pero sigue dando el mismo error al compilar.

Me parece que si lo declaro como Record en lugar de Tremotable pierdo la property Item_Description e Item_value.

Agradezco tu ayuda. Por mi parte voy a investigar porque da ese error al inicializar el array.
Saludos
Responder Con Cita
  #8  
Antiguo 20-07-2012
matiaslegnazzi matiaslegnazzi is offline
Registrado
NULL
 
Registrado: jul 2012
Posts: 6
Poder: 0
matiaslegnazzi Va por buen camino
No hay caso. Ya intente de mil formas y recibo el error de memoria, como si el array no estuviera inicializado. Tampoco puedo inicializarlo en la declaracion del array.
Saludos
Responder Con Cita
  #9  
Antiguo 20-07-2012
matiaslegnazzi matiaslegnazzi is offline
Registrado
NULL
 
Registrado: jul 2012
Posts: 6
Poder: 0
matiaslegnazzi Va por buen camino
SOLUCIONADO!!!!

Código Delphi [-]
 var     n: ArrayOfItem;

 ...

 setlength(n,1);
 n[0]:=Invoice_Body.create;
 n[0].Item_Descripcion:= tr_bl[1][0][0];
 n[0].Item_Value := tr_bl[1][0][1];
 result.Item:=copy(n);

Última edición por Casimiro Notevi fecha: 20-07-2012 a las 22:01:20.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Array en class(TRemotable) Miguel Galarza OOP 4 06-04-2010 22:44:05
pasar de un array de valores a bitmap i.larranaga C++ Builder 3 20-04-2007 05:01:04
valores diferentes en array anubis Varios 6 17-04-2007 09:47:39
Cómo asignar valores a una variable tipo Array quinqui OOP 7 23-06-2006 15:59:17


La franja horaria es GMT +2. Ahora son las 09:02:31.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi