Bonjour,

J'ai un fichier text du type :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
0.94902;0.839216;0;Medium Yellow C
0.866667;0.368627;0;Bright Orange C
0.819608;0.219608;0.207843;Bright Red C
0.678431;0;0.388235;Strong Red C
0.698039;0.14902;0.576471;Pink C
0.247059;0;0.54902;Medium Purple C
J'ai écris une procedure du type :
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
 
procedure LisFichier( const FileName: TFileName;
                            var Rec : MonType);
var
  F: TextFile;
  St,S,S0: String;
  J,i: integer;
  C: char;
  R,G,B: single;
begin
  AssignFile(F, FileName);
  Reset(F);
  while not Eof(F) do
  begin
    ReadLn(F, St);
    S:='';
    J:=0;
    for i:=1 to Length(St) do
    begin
      C:= St[i];
      if C<>';' then S:= S+C else
      if (C=';') or (i=Length(St)) then
      begin
        inc(J);
        case J of
          1: R:= StrToFloat(S);
          2: G:= StrToFloat(S);
          3: B:= StrToFloat(S);
          4: S0:= S;
        end;
        S:= '';
      end;
    end;
  end;
  CloseFile(F);
end;
Si je trace cette procedure lorsque J=1 à 3 S correspond bien à la string d'un nombre flottant et si J=4 S à du texte

Mais pour J=1..3 Le StrToFloat(S) ne fonctionne pas car R,G ou B ne sont pas initialisé par la valeur de S mais si J=4 S0 est bien initialisé par S!!!

Où est le problème ???