Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

Tema Cerrado
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-03-2011
ferjavrec2 ferjavrec2 is offline
Registrado
 
Registrado: may 2007
Posts: 7
Poder: 0
ferjavrec2 Va por buen camino
Problema al asignar valor a array

Hola buenas tardes, les quiero pedir si me pueden ayudar con este error que tengo ya que no lo he podido soluccionar aun. Estoy haciendo un sistema para autorizar factura electronicas y al querer asignar un valor al array me sale un error "Access violation at address 00531246 in module 'Project1.exe'. Read of address 00000000"

aca dejo la forma como cargo un dato al array:
Código Delphi [-]
var
 prueba: ArrayOfFEDetalleRequest;
begin
 prueba[0].tipo_doc := 80;

end;


Y aca dejo parte del WebService:
Código Delphi [-]
ArrayOfFEDetalleRequest = array of FEDetalleRequest;


  // ************************************************************************ //
  // XML       : FERequest, global, 
  // Namespace :
  // ************************************************************************ //
  FERequest = class(TRemotable)
  private
    FFecr: FECabeceraRequest;
    FFecr_Specified: boolean;
    FFedr: ArrayOfFEDetalleRequest;
    FFedr_Specified: boolean;
    procedure SetFecr(Index: Integer; const AFECabeceraRequest: FECabeceraRequest);
    function  Fecr_Specified(Index: Integer): boolean;
    procedure SetFedr(Index: Integer; const AArrayOfFEDetalleRequest: ArrayOfFEDetalleRequest);
    function  Fedr_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property Fecr: FECabeceraRequest        Index (IS_OPTN) read FFecr write SetFecr stored Fecr_Specified;
    property Fedr: ArrayOfFEDetalleRequest  Index (IS_OPTN) read FFedr write SetFedr stored Fedr_Specified;
  end;



  // ************************************************************************ //
  // XML       : FEDetalleRequest, global, 
  // Namespace :
  // ************************************************************************ //
  FEDetalleRequest = class(TRemotable)
  private
    Ftipo_doc: Integer;
    Fnro_doc: Int64;
    Ftipo_cbte: Integer;
    Fpunto_vta: Integer;
    Fcbt_desde: Int64;
    Fcbt_hasta: Int64;
    Fimp_total: Double;
    Fimp_tot_conc: Double;
    Fimp_neto: Double;
    Fimpto_liq: Double;
    Fimpto_liq_rni: Double;
    Fimp_op_ex: Double;
    Ffecha_cbte: string;
    Ffecha_cbte_Specified: boolean;
    Ffecha_serv_desde: string;
    Ffecha_serv_desde_Specified: boolean;
    Ffecha_serv_hasta: string;
    Ffecha_serv_hasta_Specified: boolean;
    Ffecha_venc_pago: string;
    Ffecha_venc_pago_Specified: boolean;
    procedure Setfecha_cbte(Index: Integer; const Astring: string);
    function  fecha_cbte_Specified(Index: Integer): boolean;
    procedure Setfecha_serv_desde(Index: Integer; const Astring: string);
    function  fecha_serv_desde_Specified(Index: Integer): boolean;
    procedure Setfecha_serv_hasta(Index: Integer; const Astring: string);
    function  fecha_serv_hasta_Specified(Index: Integer): boolean;
    procedure Setfecha_venc_pago(Index: Integer; const Astring: string);
    function  fecha_venc_pago_Specified(Index: Integer): boolean;
  published
    property tipo_doc:         Integer  read Ftipo_doc write Ftipo_doc;
    property nro_doc:          Int64    read Fnro_doc write Fnro_doc;
    property tipo_cbte:        Integer  read Ftipo_cbte write Ftipo_cbte;
    property punto_vta:        Integer  read Fpunto_vta write Fpunto_vta;
    property cbt_desde:        Int64    read Fcbt_desde write Fcbt_desde;
    property cbt_hasta:        Int64    read Fcbt_hasta write Fcbt_hasta;
    property imp_total:        Double   read Fimp_total write Fimp_total;
    property imp_tot_conc:     Double   read Fimp_tot_conc write Fimp_tot_conc;
    property imp_neto:         Double   read Fimp_neto write Fimp_neto;
    property impto_liq:        Double   read Fimpto_liq write Fimpto_liq;
    property impto_liq_rni:    Double   read Fimpto_liq_rni write Fimpto_liq_rni;
    property imp_op_ex:        Double   read Fimp_op_ex write Fimp_op_ex;
    property fecha_cbte:       string   Index (IS_OPTN) read Ffecha_cbte write Setfecha_cbte stored fecha_cbte_Specified;
    property fecha_serv_desde: string   Index (IS_OPTN) read Ffecha_serv_desde write Setfecha_serv_desde stored fecha_serv_desde_Specified;
    property fecha_serv_hasta: string   Index (IS_OPTN) read Ffecha_serv_hasta write Setfecha_serv_hasta stored fecha_serv_hasta_Specified;
    property fecha_venc_pago:  string   Index (IS_OPTN) read Ffecha_venc_pago write Setfecha_venc_pago stored fecha_venc_pago_Specified;
  end;

Bueno desde ya muchas gracias por su tiempo.
saludos
  #2  
Antiguo 04-03-2011
Avatar de Crandel
[Crandel] Crandel is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Parana, Argentina
Posts: 1.475
Poder: 23
Crandel Va por buen camino
prueba es del tipo ArrayOfFEDetalleRequest que a su vez es un array dinamico, por lo que debes definir un tamaño a ese vector antes de poder asignarle elementos.

Por ejemplo pon esta linea antes de la asignación:

Código Delphi [-]
SetLength(prueba, 1);
.
__________________
[Crandel]
  #3  
Antiguo 04-03-2011
ferjavrec2 ferjavrec2 is offline
Registrado
 
Registrado: may 2007
Posts: 7
Poder: 0
ferjavrec2 Va por buen camino
Mira en realidad yo me confundi cuando declaro el array, esta es la forma que seria, en la cual me genera el error. De todas formas probe con SetLength y sigue haciendo el mismo error:

Código Delphi [-]
var
 prueba: FERequest;
begin
 prueba := FERequest.Create;
 prueba.Fedr[0].tipo_doc := 80;
end;

Bueno, muchas gracias a todos.
saludos
  #4  
Antiguo 04-03-2011
Avatar de Crandel
[Crandel] Crandel is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Parana, Argentina
Posts: 1.475
Poder: 23
Crandel Va por buen camino
Te quedaría asi:

Código Delphi [-]
var
 prueba: FERequest;
begin
 prueba := FERequest.Create;
 SetLength(prueba.FFedr,1);
 prueba.FFedr[0] := FEDetalleRequest.Create;
 prueba.FFedr[0].Ftipo_doc := 80;
end;

primero SetLength le da un tamaño a tu vector dinamico y segundo como cada elemento de ese vector es puntero a un objeto debes crear el objeto antes.

Con esto ya no deberias tener problemas
__________________
[Crandel]
  #5  
Antiguo 04-03-2011
ferjavrec2 ferjavrec2 is offline
Registrado
 
Registrado: may 2007
Posts: 7
Poder: 0
ferjavrec2 Va por buen camino
Muchas gracias por tu respuesta, mira te cuento que me da error en la linea SetLength(prueba.Fedr,1);:

[DCC Error] Unit1.pas(113): E2197 Constant object cannot be passed as var parameter

muchas gracias
  #6  
Antiguo 04-03-2011
Avatar de Crandel
[Crandel] Crandel is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Parana, Argentina
Posts: 1.475
Poder: 23
Crandel Va por buen camino
nop, no puedes darle el tamaño a esa propiedad desde afuera, deberas agregar un metodo para eso
__________________
[Crandel]

Última edición por Crandel fecha: 04-03-2011 a las 20:55:14.
  #7  
Antiguo 06-03-2011
ferjavrec2 ferjavrec2 is offline
Registrado
 
Registrado: may 2007
Posts: 7
Poder: 0
ferjavrec2 Va por buen camino
ok, muchas gracias, ya lo pude soluccionar.
saludos
Tema Cerrado



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
Asignar 'array property' con record.elemento yapt OOP 6 13-05-2010 21:16:05
Error al asignar un valor ioco Lazarus, FreePascal, Kylix, etc. 3 14-02-2010 15:06:59
Problema al asignar valor antes de visualizar el form drykea Varios 20 19-01-2009 17:38:37
Cómo asignar valores a una variable tipo Array quinqui OOP 7 23-06-2006 15:59:17
Como Asignar Variable Tipo Array de Tform a otro Array del Mismo tipo morfeo21 Varios 5 17-08-2004 17:39:51


La franja horaria es GMT +2. Ahora son las 14:51: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