Pas mal de code mort.
Ex: Lignes 28,29, 2 x reset ! z ? bl ?
(Pleins d'essais ??
![;) ;)]()
)
Bon, tu as oublié de réinitialiser y !!!!!
Ca donne :
Program joueursH;
uses dos,crt,printer;
const
ecran=$b800 ;
var
f:text;
ligne:string;
j,k,y:integer;
clt:string;
nomjou:string;
prenom:string;
affi:string;
lf:string;
nclub:string;
sep:array[1..40] of byte;
begin
clrscr;
assign(f,'e:\tennis\advers.txt'); {ouverture du fichier texte }
{$i-} reset(f); {$i+}
while not eof(f) do
{je lis l'entiereté du fichier (je ne pourrais accéder à une 4èmè ligne qu'en lisant les 4 premières et en exploitant la dernière et c'est là que cela ne va plus }
begin
{ Init ici !!! }
{ mise à blanc de mes variables }
for k:=1 to 5 do sep[k]:=0;
readln(f,ligne);
y := 0; { <-- Init !!! }
for j:=1 to length(ligne) do {je détermine les positions du caractère chr(9) qui sépare mes variables à trouver}
begin
if (ligne[j])=chr(9) then
begin
y:=y+1;
if y > 40 then begin
writeln ( 'ET LA GESTION DES ERREURS NOM D'UN ORDI EN BOIS !' );
halt ( 0 );
end;
sep[y]:=j; { <-- x devient j !!! }
end;
end;
nclub := ''; { <-- Init ici }
for k:= 1 to sep[1]-1 do
{je lis les lignes caractères par caractères pour obtenir la valeur de mes variables ceci marche pour la première ligne mais pas pour les autres }
begin
nclub:=nclub+ligne[k] ;
end;
lf := '';
for k:= sep[1]+1 to sep[2]-1 do
begin
lf:=lf+ligne[k] ;
end;
nomjou := ''; { <-- Init ici }
for k:=sep[2]+1 to sep[3]-1 do
begin
nomjou:=nomjou+ligne[k];
end;
prenom := ''; { <-- Init ici }
for k:=sep[3]+1 to sep[4]-1 do
begin
prenom:=prenom+ligne[k];
end;
clt := ''; { <-- Init ici }
for k:=sep[4]+1 to sep[5]-1 do
begin
clt:=clt+ligne[k];
end;
affi := '';
for k:=sep[5]+1 to l do
begin
affi:=affi+ligne[k];
end;
end;
close(f);
end.
Mais ce n'est vraiment pas beau comme code. Et si tu découvrais les fonctions POS et COPY !
Exemple à étudier :
procedure LireFichier(const filename: String);
const
SEP = #9;
var
f : TextFile;
s : String;
p, q : Integer;
begin
assign(f, filename);
{$i-} reset(f); {$i+}
while not eof(f) do
begin
readln(f, s);
p := 1;
while true do
begin
q := pos(SEP, copy(s, p, length(s) - p + 1));
if q = 0 then
begin
writeln(copy(s, p, length(s) - p + 1));
break;
end;
writeln(copy(s, p, q - 1));
p := q + 1;
end;
end;
closefile(f);
end;