Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-04-2006
Avatar de halcon_rojo
halcon_rojo halcon_rojo is offline
Miembro
 
Registrado: abr 2006
Posts: 14
Poder: 0
halcon_rojo Va por buen camino
otro tip

gracias Alvaro por tu interes, tal vez se deba a algun 'error' en el archivo de texto, de todos modos mi pregunta es si cargaste el archivo de 10Mb en el TStringList y lo recorriste? o solo lo cargaste?
acerca de mi otra duda de por que me demora tanto la carga y al tener en mi codigo una llamada repetitiva del ProcessMessages encontre este comentario:

In your loop you need to add a call to the Application.ProcessMessages method. This will allow your application to process Windows messages, including those generated by user actions. There are two significant caveats. First, since Windows messages often translate into calls to event handlers your program may begin to do things at inappropriate times. Make sure that the user can't initiate actions that will interfere with the loop while the loop is active. In particular, note the following sentence, taken from Delphi 3's help file on TApplication.Terminated: "For applications using calculation-intensive loops, call Application.ProcessMessages periodically, and also check Application.Terminated to determine whether or not to abort the calculation so that the application can terminate." The second caveat is that calling Application.ProcessMessages can be relatively expensive and may slow the program. In a fast (tight) loop you may not want to call the method on each iteration. If you only want to update the display and not handle user input you can use the Update method (Delphi 3 and up) of the control covering the part of the display you want to update. Remember that this will also slow down the loop!

Última edición por halcon_rojo fecha: 12-04-2006 a las 22:02:33.
Responder Con Cita
  #2  
Antiguo 12-04-2006
alapaco alapaco is offline
No confirmado
 
Registrado: jun 2003
Ubicación: Buenos Aires
Posts: 287
Poder: 0
alapaco Va por buen camino
Exacto, eso que remarcaste en rojo es correcto, tal vez sería mejor llamar a Application.ProcessMessages cada X cantidad de registros procesados, no cada 1.
Responder Con Cita
  #3  
Antiguo 16-05-2006
JCarlosas JCarlosas is offline
Miembro
 
Registrado: abr 2006
Ubicación: Habana. Cuba
Posts: 103
Poder: 21
JCarlosas Va por buen camino
Hola.
Me estuve leyendo el fragmento que esta en ingles pues casualmente soy uno de los que tiene el problema con el caracter #0.
Me estaba ocurriendo que cuando leia el archivo con
LoadFromFile
y dicho archivo contenia en algun lugar el caracter #0 se me cortaba ahi el archivo no seguia cargando.
Quizas la solucion del problema le sea util a alguien y aqui se las dejo.
En el fuente solamente lo que hice fue cambiar el caracter #0 que venia por un caracter A, quizas en otras aplicaciones se deba hacer otra cosa pero creo que el ejemplo vale.


Código Delphi [-]
unit UCustomTStrings;
{$R-,T-,X+,H+,B-}
{$IFDEF MSWINDOWS}
{ ACTIVEX.HPP is not required by CLASSES.HPP }
(*$NOINCLUDE ActiveX*)
{$ENDIF}
{$IFDEF LINUX}
{$DEFINE _WIN32}
{$ENDIF}
{$IFDEF MSWINDOWS}
{$DEFINE _WIN32}
{$ENDIF}

interface
{$IFDEF MSWINDOWS}
uses Windows, Messages, SysUtils, Variants, TypInfo, ActiveX, classes;
{$ENDIF}
{$IFDEF LINUX}
uses Libc, SysUtils, Variants, TypInfo, Types, classes;
{$ENDIF}
 type
  TCustomTStrings = class(TStringList)
  Public
   procedure LoadFromStream(Stream: TStream);Virtual;
   procedure LoadFromFile(const FileName: string);Virtual;
  end;
implementation
uses strutils;
procedure TCustomTStrings.LoadFromFile(const FileName: string);
var
  Stream: TStream;
begin
  Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
  try
    LoadFromStream(Stream);
  finally
    Stream.Free;
  end;
end;
 
procedure TCustomTStrings.LoadFromStream(Stream: TStream);
var
  Size: Integer;
  S : string;
  i: integer;
  StringSize : integer;
begin
  BeginUpdate;
  try
    Size := Stream.Size - Stream.Position;
    SetString(S, nil, Size);
    Stream.Read(Pointer(S)^, Size);
    StringSize := Length(S);

//Este for es solamente para cambiar el caracter #0 por otro.
    for i:= 1 to StringSize do
      Begin
         if S[i] = #0 then S[i] := 'A'; //Sustituyendo el #0 por  una "A"
      end;

 
    SetTextStr(S);
  finally
    EndUpdate;
  end;
end;
end.

Ah y la llamada y creacion del nuevo componente muy facil.

Código Delphi [-]
var
  tsArchivo : TCustomTStrings;
Begin
 tsArchivo := TCustomTStrings.create;
 tsArchivo.LoadFromFile(LoteFileName);

Otra variante pudo ser redefinir el metodo
SetTextStr
en lugar de loadfromstream

Por cierto he cargado archivos de mas de 100MBytes con ese codigo

Espero que sea de utilidad a alguien.
Saludos
Juan Carlos

Última edición por JCarlosas fecha: 16-05-2006 a las 01:47:44.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
Capacidad de Paradox irvingcm Tablas planas 3 13-04-2005 00:41:59
Cual es el limite de capacidad de Paradox? URBANO Tablas planas 1 15-03-2005 09:54:12
Saber exactamente cual es cual en un DBLookUpComboBox bustio OOP 3 03-02-2005 23:16:58
Capacidad del QReport marila Impresión 2 22-04-2004 16:02:47
Capacidad No soportada con BDE GIVO Conexión con bases de datos 3 27-08-2003 03:10:09


La franja horaria es GMT +2. Ahora son las 09:05:10.


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