Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #5  
Antiguo 03-11-2023
ArtPortEsp ArtPortEsp is offline
Miembro
 
Registrado: may 2018
Ubicación: Mexico
Posts: 151
Poder: 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
 



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
problema son StrToFloat juggern Varios 13 28-02-2023 10:19:07
Errores en la conversión usando StrToFloat juggern Varios 2 07-09-2020 02:30:37
Listview Problema en StrToFloat pablonill OOP 3 01-08-2008 13:01:17
StrtoFloat mjjj Varios 2 27-12-2007 18:32:06
Problemas con StrToFloat MaMu Varios 1 08-07-2007 09:25:10


La franja horaria es GMT +2. Ahora son las 09:36:51.


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