Ver Mensaje Individual
  #27  
Antiguo 16-06-2014
Avatar de jafera
jafera jafera is offline
Miembro
 
Registrado: may 2007
Ubicación: Llagostera (Girona)
Posts: 582
Reputación: 18
jafera Va por buen camino
Hechas las primeras pruebas, la primera linea empieza por......tachan..... , pero en el codigo puesto, lo he modificado así:

Código Delphi [-]
procedure TF_Importa.Button1Click(Sender: TObject);
var
  Registro : string;
  Datos, ficherotemporal : TextFile;
  caracteresignorar : integer;
  PrimeraLinea : Boolean;
  sl:tstringlist;
begin
           if opendialog1.Execute then
           begin
           AssignFile(Datos,  OpenDialog1.FileName);
           Reset(Datos);
           CaracteresIgnorar := 0;
           try
              while not EOF(Datos) do
              begin
                 ReadLn(Datos, Registro);
                 {En la primera linea debo ver si es un archivo UTF y ver cuantos caracteres debo ignorar}
                 if (PrimeraLinea) then
                 begin
                    if (Ord(Registro[1]) = $EF) and (Ord(Registro[2]) = $BB) and (Ord(Registro[3]) = $BF) then {Posiblemente UTF8}
                       CaracteresIgnorar := 3;
                    Registro := copy(Registro,CaracteresIgnorar, Length(Registro));
                 end;
                 // Agrego Registro a un StringList
                 sl.Add(Registro);
              end; // while
              // Grabo el StringList a un fichero Temporal
              sl.SaveToFile('C:\Rebuts_1.0\Fitxers\Ranking\FicheroTemporal.txt');
              finally
              // importo el fichero temporal
              end;
           end;
end;

ejecutando paso a paso , me dice que primeralinea := False, o sea que no pasa por el caracteresIgnorar y viendo que vale registro y siendo realmente la primera linea pues empieza por los caracteres descritos.

Algo sigo haciendo mal

Gracias

Josep
Responder Con Cita