Ver Mensaje Individual
  #5  
Antiguo 03-11-2023
ArtPortEsp ArtPortEsp is offline
Miembro
 
Registrado: may 2018
Ubicación: Mexico
Posts: 151
Reputación: 7
ArtPortEsp Va por buen camino
Pues ya lo hice funcionar, pero tal parece que necesito aprender Delphi otra vez, el primer código es el que no funciona, (nota: le he estado haciendo cambios)...
subo el código...
Código Delphi [-]
procedure Leerecibo;
var
     xrec_linea,xrec_campos : integer;
     xrec_seccionxml,xrec_fields,xrec_values,xrec_secciones,xrec_subsecciones,xmientras : string;
     xrec_campo : widestring;
     xrec_valor : widestring;
     xrec_texto : widestring;
     xrec_estexto,xrec_seccion,xrec_subseccion : boolean;
     xrectotal,xrecsubtotal,xrecprima,xrecgasto,xrecderecho,xreciva,xrectc : double;

begin
     xrec_subsecciones:='Descripcion,Importe';
     xrec_values      :='prima,derechos,gasto,prima de la poliza,gastos de expedición';

     xrectotal    := 0;
     xrecsubtotal := 0;
     xrecprima    := 0;
     xrecgasto    := 0;
     xrecderecho  := 0;
     xreciva      := 0;

     for xrec_linea := 0 to XML.Tags.Count-1 do
     begin
          if XML.Tags[xrec_linea].name='?xml' then continue;

          xrec_seccionxml := XML.Tags[xrec_linea].name;

          for xrec_campos:=0 to XML.Tags[xrec_linea].AttributeCount - 1 do
          begin
               xrec_campo := XML.Tags[xrec_linea].Attributes[xrec_campos].Name;
               xrec_valor := UTF8Decode(XML.Tags[xrec_linea].Attributes[xrec_campos].Value);

               // obtencion de totales del recibo
               if Ansilowercase(xrec_campo) = 'subtotal'   then
                    xrecsubtotal := strtofloatdef(xrec_valor,0);
               if Ansilowercase(xrec_campo) = 'total'      then
                    xrectotal    := strtofloatdef(xrec_valor,0);
               if Ansilowercase(xrec_campo) = 'tipocambio' then
                    xrectc       := strtofloatdef(xrec_valor,0);


y este es el codigo que ya funciona:
Código Delphi [-]
var
     LineasXML : Tstringlist;
     XML       : TclHtmlParser;
     xrectotal,xrecsubtotal,xrecprima,xrecgasto,xrecderecho,xreciva,xrectc : double;


implementation
uses UDM,Ufunciones,umain, Dialogs;

procedure Leerecibo;
var
     xrec_linea,xrec_campos : integer;
     xrec_seccionxml,xrec_fields,xrec_values,xrec_secciones,xrec_subsecciones,xmientras : string;
     xrec_campo : widestring;
     xrec_valor : widestring;
     xrec_texto : widestring;
     xrec_estexto,xrec_seccion,xrec_subseccion : boolean;
begin
     xrec_subsecciones:='Descripcion,Importe';
     xrec_values      :='prima,derechos,gasto,prima de la poliza,gastos de expedición';

     xrectotal    := 0;
     xrecsubtotal := 0;
     xrecprima    := 0;
     xrecgasto    := 0;
     xrecderecho  := 0;
     xreciva      := 0;

     for xrec_linea := 0 to XML.Tags.Count-1 do
     begin
          if XML.Tags[xrec_linea].name='?xml' then continue;

          xrec_seccionxml := XML.Tags[xrec_linea].name;

          for xrec_campos:=0 to XML.Tags[xrec_linea].AttributeCount - 1 do
          begin
               xrec_campo := XML.Tags[xrec_linea].Attributes[xrec_campos].Name;
               xrec_valor := UTF8Decode(XML.Tags[xrec_linea].Attributes[xrec_campos].Value);

               // obtencion de totales del recibo
               if Ansilowercase(xrec_campo) = 'subtotal'   then
                    xrecsubtotal := strtofloatdef(xrec_valor,0);
               if Ansilowercase(xrec_campo) = 'total'      then
                    xrectotal    := strtofloatdef(xrec_valor,0);
               if Ansilowercase(xrec_campo) = 'tipocambio' then
                    xrectc       := strtofloatdef(xrec_valor,0);

El valor que llegaba es '6532.74'... (en mexico usamos el . como separador decimal)

Lo unico que hice fue declarar las mismas variables fuera del procedimiento, para mi no tiene logica, por que no funciono cuando las variables estaban declaradas dentro del procedimiento?

Última edición por Casimiro Notevi fecha: 03-11-2023 a las 12:36:25. Razón: Poner etiquetas [delphi] [/delphi] al código.
Responder Con Cita