procedure TForm7.lignes; var S,L,lign_prec: string; //--Note que l'on utilise le type string i, J: Integer; SL: TStringList; begin SL := TStringList.Create; try SL.LoadFromFile(ExtractFilePath(Application.ExeName)+'/temp/PGP_DEM_raw.log'); for J := 0 to SL.Count - 1 do begin S := SL[J]; L:= copy(S,0,49); S:=copy(S,pos(']',S)+1,length(S)); if pos('[ETB]',S)>0 then lign_prec:=copy(S,0,pos('[ETB]',S)-1) else if (S<>' ') and (copy(S,2,2)<>'H|') and (copy(S,2,2)<>'L|') then begin i:=i+1; memo1.Lines.Append(lign_prec+S); lign_prec:=''; Label2.Caption:=intToStr(i); end; end; memo1.Lines.Append('Timestamp dernière ligne '+L); finally SL.Free; end; end;
{$IFDEF UNICODE} Le code placé ici compilera à partir de Delphi 2009 - XE3 ... string = WideString Char = WideChar PChar = PWideChar {$ELSE} Le code placé ici compilera sur les versions antérieurs (D4 - D7 ...) string = AnsiString Char = AnsiChar PChar = PAnsiChar {$ENDIF}[hr]@+Cirec
[TStringList / TStrings].LoadFromFile(nom, TEncoding.{Encodage d'origine}); {traitement} [TStringList / TStrings].SaveToFile(nom, TEncoding.{ANSI ou UTF8});
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question//-------------Lecture lignes pour mettre en mémoire------------------- procedure TForm1.lignes; var F: textfile; S,L,lign_prec: UnicodeString; //--j'ai assayé String et AnsiString mais pas mieux-- i: Integer; begin AssignFile(F,ExtractFilePath(Application.ExeName)+'/temp/PGP_DEM_raw.log'); Reset(F); repeat Readln(F,S); L:= copy(S,0,49); S:=copy(S,pos(']',S)+1,length(S)); if pos('[ETB]',S)>0 then lign_prec:=copy(S,0,pos('[ETB]',S)-1) else if (S<>' ') AND (copy(S,2,2)<>'H|') AND (copy(S,2,2)<>'L|') then begin i:=i+1; memo1.Lines.Append(lign_prec+S); lign_prec:=''; Label2.Caption:=intToStr(i); end; until EOF(F); memo1.Lines.Append('Timestamp dernière ligne '+L); end; //-------------MAIN PRGM----------------------------------------- procedure TForm1.Button1Click(Sender: TObject); begin Debut := Now; copie_fichier(self); ligne1(self); lignes(self); Label1.Caption:= IntToStr(SecondsBetween(Debut,Now)); end;