1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tfrm_main = class(TForm)
Memo1: TMemo;
btn_ok: TButton;
procedure FormCreate(Sender: TObject);
procedure btn_okClick(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
frm_main: Tfrm_main;
implementation
{$R *.dfm}
procedure Tfrm_main.btn_okClick(Sender: TObject);
Var F: TextFile;
Stg:String;
begin
//Lire le contenu du fichier
Memo1.Clear; //Efface le contenu de Memo1
AssignFile(F,ExtractFilePath(Application.ExeName)+'test.txt');
Reset(F);
repeat //Repeter...
Readln(F,Stg); //Lit une ligne du fichier texte jusqu'au prochain sut de ligne
Memo1.Lines.Add(Stg); //Affiche dans Memo1 le contenu de la variable
until EOF(F);// ...jusqu'à ce que la position en cours du pointeur se trouve en fin de fichier
CloseFile(F);
end;
procedure Tfrm_main.FormCreate(Sender: TObject);
begin
end;
end. |
Partager