Bonsoir,
j'ai un problème dans mon programme : "erreur runtime 100" dans la procédure de modification. Je n'arrive pas à la résoudre ; voilà je vous donne un exemple de mon code. Merci d'avance pour pour votre aide :
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
 
Program Gestion;
uses wincrt;
type
  date = record
    j:1..31;
    m:1..12;
    a:word;
  end;
  Etudiant = record
    Mat:string;
    NMPR:string[100];
    sexe:char;
    DN:date;
    Moy:real;
    Decision:char;
  end;
 
  FEtudiant=file of Etudiant;
 
var
  E, A:FEtudiant;
  Etu,et :Etudiant;
  D:date;
 
Procedure creation (var E:FEtudiant);
begin
  assign(E,'D:\TPPAS\Resultat.dat');
  rewrite(E);
end;
 
Function controle (var ch:string):boolean;
var
  i:integer;
begin
  i:=1;
  while (ch[i]in['0'..'9']) and (i <=length(ch)) do
    begin
      i:=i+1;
    end;
  if i>length(ch) then
    controle:=true
  else
    controle:=false;
end;
 
Procedure Matricule (var M:string);
begin
  repeat
    writeln('Saisir un Matricule');
    readln(M);
  until (length(M)=6)and(controle(m)=true);
End;
 
Procedure SFG (var S:char);
begin
  repeat
    writeln('Saisir le sexe de l''etudiant');
    readln(s);
  until (Upcase (S) in ['F','G']);
end;
 
Procedure Moyenne (var M:Real);
begin
  repeat
    writeln('Saisir la moyenne');
    readln(M);
  until (M>=0) and (M<=20);
end;
 
Procedure choix (var rep:char);
begin
  repeat
    writeln('Voulez vous saisir un autre etudiant (O/N)');
    rep:=readkey;
  until (Upcase (rep) in ['O','N']);
end;
 
Function rechercher (var E:FEtudiant;x:string):integer;
var
  trouve:boolean;
begin
  reset(E);
  trouve:=false;
  while not(eof(E))and (trouve=false) do
    begin
      read(E,Etu);
      if Etu.mat=x then
        trouve:=true;
    end;
  if trouve=true then
    rechercher:=filepos(e)
  else
    rechercher:=-1;
end;
 
Procedure Saisie (var E:FEtudiant);
var
  rep:char;
begin
  repeat
    with Etu do
      begin
        Matricule(Mat);
        Writeln('Donner le nom et le prénom');
        readln(NMPR);
        SFG(sexe);
 
        Moyenne(Moy);
        if Moy>9.75 then
          Decision:='1'
        else
          Decision:='2';
      end;
    write(E, Etu);
    choix(rep);
  until (upcase(rep)='N');
End;
 
procedure Modifier (var E :FEtudiant);
var
  M:string;
  rechMat:integer;
  my:real;
begin
  reset(E);
  Matricule(M);
  rechMAt:=rechercher (E, M);
  if rechMat=-1 then
    writeln('Matricule incorrecte')
  else
    begin
      seek(E,rechMat);
      read(E,etu);
      if etu.moy>=9.75 then
        writeln('Modifiction incorrecte')
      else
        begin
          Moyenne(my);
          if my>=9.75 then
            begin
              etu.moy:=my;
              etu.decision:='1';
              write(E,Etu);
            end
          else
            begin
              etu.moy:=my;
              etu.decision:='3';
              write(E,etu);
            end;
        end;
 
    end;
end;
 
Procedure creation1 (var A:FEtudiant);
begin
  assign(A,'D:\TPPAS\ListeAdmi.dat');
  rewrite(A);
end;
 
procedure Admis (var A:FEtudiant);
begin
  creation1(A);
  reset(E);
  while not(eof(E)) do
    begin
      read(e,etu);
      if etu.moy>=9.75 then
        write(A,etu);
    end;
end;
 
procedure Afficher (var A:FEtudiant);
var
  p:integer;
  max:real;
begin
  reset(A);
  max:=etu.moy;
  while not(eof(A)) do
    begin
      read(A,etu);
      if etu.moy>max then
        begin
          max:=etu.moy;
          p:=filepos(A);
        end;
    end;
  seek(A,p);
  with etu do
    begin
      writeln(NMPR);
      writeln(sexe);
      {val(copy(ch,DN,7),d,e)
      writeln(13-d);}
      writeln(moy:2:2);
    end;
End;
 
BEGIN
  creation(E);
  saisie(E);
  modifier(E);
  Admis (A);
  afficher(A);
  close(E);
  close(A);
END.
voila j'ai modifier la fonction recherche de cette maniere
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
 
Function rechercher (var E:FEtudiant;x:string):integer;
var
i:integer;
begin
reset(E);
i:=1;
repeat
read(E,Etu);
i:=i+1;
until (eof(E))or(etu.mat=x);
if etu.mat=x then
rechercher:=i
else
rechercher:=-1;
end;
mais j'aurais le même prob du runtime 100 je pense que ce prob réside dans la procedure modifier mais j'arrive pas à résoudre.