Bonjour, je suis nouveau et je debute en Delphi j'aimerai qu'une ame charitable m'explique ce qui cloche dans mon petit code ? Je souhaite crée une function pour lire dans un fichier .PPM (Format d'image) en ayant la possibilité de choisir le nombre d'octect a lire.

Voici mon code en esparant des réponse, voir des aides, merci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
51
52
53
unit ppm;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
 
type
  TForm1 = class(TForm)
    Image1: TImage;
    OpenDialog1: TOpenDialog;
    Button1: TButton;
    F: TFilestream;
    procedure Button1Click(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;
 
var
  Form1: TForm1;
 
implementation
 
function lecture(a: string;b: integer):string;
var buf: string;
var carac: char;
var i: integer;
var f: file of char;
begin;
assignfile(F,a);
for i:=1 to b do begin;
read(f,carac);
buf:=buf+carac;
end;
lecture:=buf;
end;
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
buffer: string;
f: file of char;
filename: string;
begin
if opendialog1.execute then filename:=opendialog1.filename;
showmessage(lecture(filename,2));
end;
 
end.