Pascal/Turbo Pascal - problemas con exitcode=2 ayuda....!

 
Vista:

problemas con exitcode=2 ayuda....!

Publicado por luis felipe (6 intervenciones) el 26/11/2012 20:35:02
Estoy haciendo un programa en pascal para la universidad que consiste en crear una especie de base de datos de estudiantes, pero cuando lo pongo a correr me aparece el mensaje exitcode=2 error, si alguien me pudiera ayudar se lo agradeceria con el alma aqui les dejo lo que tengo para que lo revisen y me dijan donde pudiese estar el error,


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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
program trabajo_universidad;
uses crt;
 
type
 tipoPersona=record
  nombrecompleto: string[80];
  edad:byte;
  direccion:string[100];
  ci:real;
  carnet:real;
  tlf:real;
  sexo:string[40];
  centroestudio:string[60];
 end;
 
const
 capacidad=10000;
 
var
 gente: array[1..capacidad] of tipoPersona;
 cantidad:integer;
 terminado: boolean;
 
procedure mostrarmenu;
 
 begin
 gotoxy(20,1);
 writeln('Universidad Nacional Experimental Asuncion');
 gotoxy(20,2);
 writeln('facultad de ingenieria');
 gotoxy(20,5);
 writeln('programa para el registro y control de estudiantes');
 gotoxy(1,8);
 writeln('1-A¤adir un nuevo estudiante');
 writeln('2-Modificar datos de un estudiante');
 writeln('3-Eliminar un estudiante');
 writeln('4-ver nombres de todos los estudiantes');
 writeln('5-Buscar un estudiante');
 writeln('6-Informe general');
 writeln('0-Salir');
 end;
 
function leeropcion : integer;
 var
  opcion:integer;
 begin
  write('escoja una opcion: ');
  readln(opcion);
  writeln;
  if (opcion=0) then terminado := true;
  leeropcion:=opcion;
 end;
 
procedure cargardatos;
 var
  fichero: file of tipopersona;
  i:integer;
 begin
  assign(fichero,'UNA.dat');
  reset(fichero);
  if ioresult<>0 then
   writeln('no habia fichero de datos. se creara uno.')
  else
  begin
   cantidad:=filesize(fichero);
   for i:=1 to cantidad do
    read(fichero, gente[i]);
   close (fichero);
  end;
 end;
 
procedure grabardatos;
 var
  fichero:file of tipopersona;
  i:integer;
 begin
  assign(fichero, 'UNA.dat');
  rewrite(fichero);
  if ioresult<>0 then
   writeln('­no se ha podido grabar­')
  else
  begin
   for i:=1 to cantidad do
    write(fichero, gente[i]);
   close (fichero);
  end;
 end;
 
procedure nuevodato;
 begin
 if(cantidad < capacidad) then
  begin
  inc(cantidad);
  writeln('introduciendo el estudiante ', cantidad);
 
  write('intoduzca el nombre del estudiante: ');
  readln(gente [cantidad].nombrecompleto);
 
  write('introduzca la edad del estudiante: ');
  readln(gente [cantidad].edad);
 
  write('introduzca la direccion del estudiante: ');
  readln(gente [cantidad].direccion);
 
  write('introduzca la cedula de identidad del estudiante: ');
  readln(gente [cantidad].ci);
 
  write('introduzca el numero de carnet del estudiante: ');
  readln(gente [cantidad].carnet);
 
  write('introduzca el telefono del estudiante: ');
  readln(gente [cantidad].tlf);
 
  write('introduzca el sexo del estudiante: ');
  readln(gente [cantidad].sexo);
 
  write('introduzca el centro de estudio del estudiante:Caracas,Barquisimeto,Merida,Zulia,Nueva Esparta,Falcon');
  readln(gente [cantidad].centroestudio);
 
  writeln;
  grabardatos;
  end
  else
   writeln('base de datos llena');
 end;
 
procedure modificardatos;
 var
  textobuscar:real;
  encontrado:boolean;
  i: integer;
 begin
  write('ingrese el numero de cedula del estudiante, para modificar los datos');
  readln(textobuscar);
  encontrado:= false;
  for i :=1 to cantidad do
   if pos (textobuscar, gente[i].ci) >0 then
    begin
     encontrado:=true;
     write('intoduzca el nombre del estudiante: ');
     readln(gente [cantidad].nombrecompleto);
 
     write('introduzca la edad del estudiante: ');
     readln(gente [cantidad].edad);
 
     write('introduzca la direccion del estudiante: ');
     readln(gente [cantidad].direccion);
 
     write('introduzca la cedula de identidad del estudiante: ');
     readln(gente [cantidad].ci);
 
     write('introduzca el numero de carnet del estudiante: ');
     readln(gente [cantidad].carnet);
 
     write('introduzca el telefono del estudiante: ');
     readln(gente [cantidad].tlf);
 
     write('introduzca el sexo del estudiante: ');
     readln(gente [cantidad].sexo);
 
     write('introduzca el centro de estudio del estudiante:Caracas,Barquisimeto,Merida,Zulia,Nueva Esparta,Falcon');
     readln(gente [cantidad].centroestudio);
 
     writeln;
     grabardatos;
    end;
  end;
 
procedure eliminar;
 var
  textobuscar:real;
  encontrado:boolean;
  i:integer;
 
  tec: char;
  p:longint;
  borra:longint;
  cont:longint;
  fichero:file of tipopersona;
  info: tipoPersona;
  ten:file of tipoPersona;
 begin
 write('ingerese la cedula del estudiante a buscar');
 readln(textobuscar);
 encontrado:=false;
 for i:=1 to cantidad do
  if pos (textobuscar, gente[i].ci) > 0 then
  begin
   encontrado:= true;
   writeln(i, '-Nombre: ', gente[i].nombrecompleto,
   ', Edad: ', gente[i].edad,
   ', Direccion: ', gente[i].direccion,
   ', Cedula de Identidad: ', gente[i].ci,
   ', Carnet: ', gente[i].carnet,
   ', Telefono: ', gente[i].tlf,
   ', Sexo: ', gente[i].sexo,
   ', Centro de Estudio: ', gente[i].centroestudio);
   writeln;
 writeln('desea eliminar estos datos [S/N]');
 repeat
  tec:=readkey;
 until tec in['s','S','n','N'];
 if tec in['s','S'] then
  begin
   assign(ten,'temporal.dat');
   rewrite(ten);
   cont:=0;
   p:=0;
   repeat
    seek(fichero,p);
    read(fichero,info);
    if p<>borra then
     begin
      seek(ten,cont);
      write(ten,info);
      cont:=cont+1;
     end;
    p:=p+1;
   until p> filesize(fichero)-1;
   close(fichero);
   erase(fichero);
   close(ten);
   rename(ten,'UNA.dat')
  end;
  end;
 if not encontrado then
  writeln('No Se Ha Encontrado Al Estudiante');
 end;
 
 procedure mostrardatos;
 var
  i:integer;
 begin
  if cantidad=0 then
   writeln('No Hay Datos')
  else
   for i:=1 to cantidad do
    writeln(i, '', gente[i].nombrecompleto);
  writeln;
 end;
 
procedure buscardatos;
 var
  textobuscar:real;
  encontrado:boolean;
  i:integer;
 begin
  write('ingerese la cedula del estudiante a buscar');
  readln(textobuscar);
  encontrado:=false;
  for i:=1 to cantidad do
   if pos (textobuscar, gente[i].ci) > 0 then
   begin
    encontrado:= true;
    writeln(i, '-Nombre: ', gente[i].nombrecompleto,
    ', Edad: ', gente[i].edad,
    ', Direccion: ', gente[i].direccion,
    ', Cedula de Identidad: ', gente[i].ci,
    ', Carnet: ', gente[i].carnet,
    ', Telefono: ', gente[i].tlf,
    ', Sexo: ', gente[i].sexo,
    ', Centro de Estudio: ', gente[i].centroestudio);
   end;
  if not encontrado then
   writeln('No Se Ha Encontrado Al Estudiante');
  writeln;
 end;
 
procedure avisarfin;
 begin
 writeln;
 writeln('saliendo...');
 writeln('­hasta luego­');
 writeln;
 end;
 
procedure avisarerror;
 begin
 writeln;
 writeln('Opci•n incorrecta');
 writeln;
 end;
 
{cuerpo del programa}
 
begin
 terminado:=false;
 cantidad:=0;
 cargardatos;
 repeat
 
  mostrarmenu;
  case leeropcion of
   1:nuevodato;
   2:modificardatos;
   3:eliminar;
   4:mostrardatos;
   5:buscardatos;
   6:writeln('no definido'); {no tengo lista esta parte del programa aun}
   0:avisarfin
   else avisarerror
  end;
 until terminado;
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

problemas con exitcode=2 ayuda....!

Publicado por ramon (2158 intervenciones) el 26/11/2012 21:26:29
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
{Primero pascal no admite estructuras tan grandes en variables normales o sea en arrays como le as cargado para ello de veras usar punteros si no el el tamaño del array tendrás que hacerlo mas pequeño.
Esto funciona pero solo e verificado asta el menú revisa y compara con el anterior tuyo }
 
program trabajo_universidad;
uses
crt;
 
type
tipoPersona=record
nombrecompleto: string[80];
edad:byte;
direccion:string[100];
ci:real;
carnet:real;
tlf:real;
sexo:string[40];
centroestudio:string[60];
end;
 
const
capacidad=10;
 
var
gente: array[1..capacidad] of tipoPersona;
cantidad:integer;
terminado: boolean;
 
procedure mostrarmenu;
 
begin
writeln;
writeln('Universidad Nacional Experimental Asuncion');
writeln;
writeln('facultad de ingenieria');
writeln;
writeln('programa para el registro y control de estudiantes');
writeln;
writeln('1-A¤adir un nuevo estudiante');
writeln('2-Modificar datos de un estudiante');
writeln('3-Eliminar un estudiante');
writeln('4-ver nombres de todos los estudiantes');
writeln('5-Buscar un estudiante');
writeln('6-Informe general');
writeln('0-Salir');
end;
 
function leeropcion : integer;
var
opcion:integer;
begin
write('escoja una opcion: ');
readln(opcion);
writeln;
if (opcion=0) then terminado := true;
leeropcion:=opcion;
end;
 
procedure cargardatos;
var
fichero: file of tipopersona;
i:integer;
begin
assign(fichero,'UNA.dat');
{$I-} reset(fichero); {$I+}
if ioresult<>0 then
writeln('no habia fichero de datos. se creara uno.')
else
begin
cantidad:=filesize(fichero);
for i:=1 to cantidad do
read(fichero, gente[i]);
close (fichero);
end;
end;
 
procedure grabardatos;
var
fichero:file of tipopersona;
i:integer;
begin
assign(fichero, 'UNA.dat');
rewrite(fichero);
if ioresult<>0 then
writeln('­no se ha podido grabar­')
else
begin
for i:=1 to cantidad do
write(fichero, gente[i]);
close (fichero);
end;
end;
 
procedure nuevodato;
begin
if(cantidad < capacidad) then
begin
inc(cantidad);
writeln('introduciendo el estudiante ', cantidad);
 
write('intoduzca el nombre del estudiante: ');
readln(gente [cantidad].nombrecompleto);
 
write('introduzca la edad del estudiante: ');
readln(gente [cantidad].edad);
 
write('introduzca la direccion del estudiante: ');
readln(gente [cantidad].direccion);
 
write('introduzca la cedula de identidad del estudiante: ');
readln(gente [cantidad].ci);
 
write('introduzca el numero de carnet del estudiante: ');
readln(gente [cantidad].carnet);
 
write('introduzca el telefono del estudiante: ');
readln(gente [cantidad].tlf);
 
write('introduzca el sexo del estudiante: ');
readln(gente [cantidad].sexo);
 
write('introduzca el centro de estudio del estudiante:Caracas,Barquisimeto,Merida,Zulia,Nueva Esparta,Falcon');
readln(gente [cantidad].centroestudio);
 
writeln;
grabardatos;
end
else
writeln('base de datos llena');
end;
 
procedure modificardatos;
var
textobuscar:real;
encontrado:boolean;
i: integer;
begin
write('ingrese el numero de cedula del estudiante, para modificar los datos');
readln(textobuscar);
encontrado:= false;
for i :=1 to cantidad do
if textobuscar = gente[i].ci then
begin
encontrado:=true;
write('intoduzca el nombre del estudiante: ');
readln(gente [cantidad].nombrecompleto);
 
write('introduzca la edad del estudiante: ');
readln(gente [cantidad].edad);
 
write('introduzca la direccion del estudiante: ');
readln(gente [cantidad].direccion);
 
write('introduzca la cedula de identidad del estudiante: ');
readln(gente [cantidad].ci);
 
write('introduzca el numero de carnet del estudiante: ');
readln(gente [cantidad].carnet);
 
write('introduzca el telefono del estudiante: ');
readln(gente [cantidad].tlf);
 
write('introduzca el sexo del estudiante: ');
readln(gente [cantidad].sexo);
 
write('introduzca el centro de estudio del estudiante:Caracas,Barquisimeto,Merida,Zulia,Nueva Esparta,Falcon');
readln(gente [cantidad].centroestudio);
 
writeln;
grabardatos;
end;
end;
 
procedure eliminar;
var
textobuscar:real;
encontrado:boolean;
i:integer;
 
tec: char;
p:longint;
borra:longint;
cont:longint;
fichero:file of tipopersona;
info: tipoPersona;
ten:file of tipoPersona;
begin
write('ingerese la cedula del estudiante a buscar');
readln(textobuscar);
encontrado:=false;
for i:=1 to cantidad do
if textobuscar = gente[i].ci then
begin
encontrado:= true;
writeln(i, '-Nombre: ', gente[i].nombrecompleto,
', Edad: ', gente[i].edad,
', Direccion: ', gente[i].direccion,
', Cedula de Identidad: ', gente[i].ci,
', Carnet: ', gente[i].carnet,
', Telefono: ', gente[i].tlf,
', Sexo: ', gente[i].sexo,
', Centro de Estudio: ', gente[i].centroestudio);
writeln;
writeln('desea eliminar estos datos [S/N]');
repeat
tec:=readkey;
until tec in['s','S','n','N'];
if tec in['s','S'] then
begin
assign(ten,'temporal.dat');
rewrite(ten);
cont:=0;
p:=0;
repeat
seek(fichero,p);
read(fichero,info);
if p<>borra then
begin
seek(ten,cont);
write(ten,info);
cont:=cont+1;
end;
p:=p+1;
until p> filesize(fichero)-1;
close(fichero);
erase(fichero);
close(ten);
rename(ten,'UNA.dat')
end;
end;
if not encontrado then
writeln('No Se Ha Encontrado Al Estudiante');
end;
 
procedure mostrardatos;
var
i:integer;
begin
if cantidad=0 then
writeln('No Hay Datos')
else
for i:=1 to cantidad do
writeln(i, '', gente[i].nombrecompleto);
writeln;
end;
 
procedure buscardatos;
var
textobuscar:real;
encontrado:boolean;
i:integer;
begin
write('ingerese la cedula del estudiante a buscar');
readln(textobuscar);
encontrado:=false;
for i:=1 to cantidad do
if textobuscar = gente[i].ci then
begin
encontrado:= true;
writeln(i, '-Nombre: ', gente[i].nombrecompleto,
', Edad: ', gente[i].edad,
', Direccion: ', gente[i].direccion,
', Cedula de Identidad: ', gente[i].ci,
', Carnet: ', gente[i].carnet,
', Telefono: ', gente[i].tlf,
', Sexo: ', gente[i].sexo,
', Centro de Estudio: ', gente[i].centroestudio);
end;
if not encontrado then
writeln('No Se Ha Encontrado Al Estudiante');
writeln;
end;
 
procedure avisarfin;
begin
writeln;
writeln('saliendo...');
writeln('­hasta luego­');
writeln;
end;
 
procedure avisarerror;
begin
writeln;
writeln('Opci•n incorrecta');
writeln;
end;
 
{cuerpo del programa}
 
begin
terminado:=false;
cantidad:=0;
cargardatos;
repeat
 
mostrarmenu;
case leeropcion of
1:nuevodato;
2:modificardatos;
3:eliminar;
4:mostrardatos;
5:buscardatos;
6:writeln('no definido'); {no tengo lista esta parte del programa aun}
0:avisarfin
else avisarerror
end;
until terminado;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por luis felipe (6 intervenciones) el 26/11/2012 21:58:51
ya realize los cambios,creo que tienes razon con lo del array y lo acomode para 10 personas como tu lo colocaste,pero todavia sigue apareciendo el exitcode=2 y la verdad no entiendo porque; si pudieras revizar el cuerpo del programa y ayudarme a tratar de encontrar una solucion te lo agradeceria con el alma, grasia de antemano por tu colaboracion
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por ramon (2158 intervenciones) el 26/11/2012 22:19:29
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
{Mira esto otro revisa los dos}
 
 
procedure buscardatos;
var
textobuscar:real;
encontrado:boolean;
i:integer;
begin
write('ingerese la cedula del estudiante a buscar');
readln(textobuscar);
encontrado:=false;
for i:=1 to cantidad do
if pos (textobuscar, gente[i].ci) > 0 then
begin
encontrado:= true;
writeln(i, '-Nombre: ', gente[i].nombrecompleto,
', Edad: ', gente[i].edad,
', Direccion: ', gente[i].direccion,
', Cedula de Identidad: ', gente[i].ci,
', Carnet: ', gente[i].carnet,
', Telefono: ', gente[i].tlf,
', Sexo: ', gente[i].sexo,
', Centro de Estudio: ', gente[i].centroestudio);
end;
if not encontrado then
writeln('No Se Ha Encontrado Al Estudiante');
writeln;
end;
 
 
 
{tuyo corregido}
 
procedure buscardatos;
var
textobuscar:real;
encontrado:boolean;
i:integer;
begin
write('ingerese la cedula del estudiante a buscar');
readln(textobuscar);
encontrado:=false;
for i:=1 to cantidad do
if textobuscar = gente[i].ci then
begin
encontrado:= true;
writeln(i, '-Nombre: ', gente[i].nombrecompleto,
', Edad: ', gente[i].edad,
', Direccion: ', gente[i].direccion,
', Cedula de Identidad: ', gente[i].ci,
', Carnet: ', gente[i].carnet,
', Telefono: ', gente[i].tlf,
', Sexo: ', gente[i].sexo,
', Centro de Estudio: ', gente[i].centroestudio);
end;
if not encontrado then
writeln('No Se Ha Encontrado Al Estudiante');
writeln;
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por luis felipe (6 intervenciones) el 27/11/2012 00:26:33
si, ya corregi este procedimiento como me lo planteaste, pero todavia sigue apareciendo el mismo error, voy a seguir revisando a ver, mientras gracias por seguirme ayudando.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por luis felipe (6 intervenciones) el 27/11/2012 01:05:59
muchas gracias ramon, revise de nuevo lo primero que me corregiste y me di cuenta de que me falto agregar algo a un procedimiento, muchas gracias; Pero ahora cuando trato de eliminar un estudiante me sale exitcode=103, y se sale el programa, a ver si me puedes ayudar con esta parte, de antemano muchisimas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por ramon (2158 intervenciones) el 27/11/2012 17:23:58
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
{Disculpa Pero en el procedimiento
 
procedure eliminar;
var
textobuscar:real;
encontrado:boolean;
i:integer;
 
tec: char;
p:longint;
borra:longint;
cont:longint;
fichero:file of tipopersona;
info: tipoPersona;
ten:file of tipoPersona;
begin
write('ingerese la cedula del estudiante a buscar');
readln(textobuscar);
encontrado:=false;
for i:=1 to cantidad do
if textobuscar = gente[i].ci then
begin
encontrado:= true;
writeln(i, '-Nombre: ', gente[i].nombrecompleto,
', Edad: ', gente[i].edad,
', Direccion: ', gente[i].direccion,
', Cedula de Identidad: ', gente[i].ci,
', Carnet: ', gente[i].carnet,
', Telefono: ', gente[i].tlf,
', Sexo: ', gente[i].sexo,
', Centro de Estudio: ', gente[i].centroestudio);
writeln;
writeln('desea eliminar estos datos [S/N]');
repeat
tec:=readkey;
until tec in['s','S','n','N'];
if tec in['s','S'] then
begin
assign(ten,'temporal.dat');
rewrite(ten);
cont:=0;
p:=0;
repeat
seek(fichero,p);
read(fichero,info);
if p<>borra then
begin
seek(ten,cont);
write(ten,info);
cont:=cont+1;
end;
p:=p+1;
until p> filesize(fichero)-1;
close(fichero);
erase(fichero);
close(ten);
rename(ten,'UNA.dat')
end;
end;
if not encontrado then
writeln('No Se Ha Encontrado Al Estudiante');
end;


estas tratando un array de registros y un archivo de registros eso no es correcto mira bien
el programa la búsqueda se debe de realizar sobre archivos directos o sobre arrays pero
nunca mezclar borras el array y creas el archivo .

forma de búsqueda y borrado de un registro de un archivo :

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
uses
    crt;
 
  type
    tipoPersona = record
     nombrecompleto : string[80];
               edad : byte;
          direccion : string[100];
                 ci : real;
             carnet : real;
                tlf : real;
               sexo : string[40];
      centroestudio : string[60];
      end;
 
   const
     capacidad = 10;
 
    var
        gente : array[1..capacidad] of tipoPersona;
     cantidad : integer;
    terminado : boolean;
 
 
   procedure eliminar;
   var
    textobuscar : real;
            tec : char;
             l, i, p : longint;
            f, ten : file of tipoPersona;
            encontre : boolean;
     begin
        write('ingerese la cedula del estudiante a buscar');
        readln(textobuscar);
        assign(f,'una.dat');
     {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     begin
        writeln('  Elfichero Nombre : Una.dat No Encontrado Pulse [Enter]');
        readln;
        exit;
     end
  else
      begin
         i := 0;
         encontre := false;
        repeat
         seek(f,i);
         read(f,gente[1]);
         if textobuscar = gente[1].ci then
         begin
            p := i;
            encontre := true;
         end
       else
          i := i + 1;
       until (encontre = true) or (i > filesize(f) - 1);
       if encontre = true then
       begin
 
          {Aqui lo que quieras poner}
          {/////////////////////////}
 
 
 
          assign(ten,'tempo.tmp');
          rewrite(ten);
          for i := 0 to filesize(f) - 1 do
          begin
              seek(f,i);
              read(f,gente[1]);
              if i <> p then
              begin
                seek(ten,l);
                write(ten,gente[1]);
                l := l + 1;
              end;
          end;
            close(f);
            erase(f);
            close(ten);
            rename(ten,'una.dat');
       end
    else
        writeln(' Cedula del Estudiante no Encontrada');
      end;
   end;
 
  procedure mostrardatos;
  var
    i : integer;
  begin
    if cantidad = 0 then
    writeln('No Hay Datos')
 else
    for i := 1 to cantidad do
     writeln(i, ' ', gente[i].nombrecompleto);
     writeln;
    end;
 
 
  begin
      eliminar;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por luis felipe (6 intervenciones) el 27/11/2012 20:01:48
ya realize las correcciones que me indicaste, pero parece que todavia hay un error, porque cuando trato de eliminar a un estudiante de prueba llega hasta la parte de (desea eliminar al estudiante s n),
y luego cuando ingreso "s" se sale el programa con el mensaje exitcode=101, de todas formas te mando el procedimiento tal cual como lo corregi para que me digas que puede estar fallando

procedure eliminar;
var
textobuscar:real;
tec: char;
l,i,p:longint;
f,ten:file of tipoPersona;
encontre:boolean;
begin
write('ingerese la cedula del estudiante a buscar');
readln(textobuscar);
assign(f,'UNA.dat');
{$l-}reset(f);{$l+}
if ioresult<>0 then
begin
writeln('el fichero nombre: UNA.dat no encontrado pulse [enter]');
readln;
exit;
end
else
begin
i:=0;
encontre:=false;
repeat
seek(f,i);
read(f,gente[1]);
if textobuscar=gente[1].ci then
begin
p:=i;
encontre:=true;
end
else
i:=i+1;
until(encontre=true) or ( i>filesize(f)-1 );
if encontre=true then
begin

writeln(i, '-Nombre: ', gente[i].nombrecompleto,
', Edad: ', gente[i].edad,
', Direccion: ', gente[i].direccion,
', Cedula de Identidad: ', gente[i].ci,
', Carnet: ', gente[i].carnet,
', Telefono: ', gente[i].tlf,
', Sexo: ', gente[i].sexo,
', Centro de Estudio: ', gente[i].centroestudio);
writeln;
writeln('desea eliminar estos datos [S/N]');
repeat
tec:=readkey;
until tec in['s','S','n','N'];
if tec in['s','S'] then
begin

assign(ten,'tempo.tmp');
rewrite(ten);
for i:=0 to filesize(f)-1 do
begin
seek(f,i);
read(f,gente[1]);
if i<>p then
begin
seek(ten,l);
write(ten,gente[1]);
l:=l+1;
end;
end;
close(f);
erase(f);
close(ten);
rename(ten,'UNA.dat');
end
else
writeln('cedula de estudiante no encontrada');
end;
end;
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problemas con exitcode=2 ayuda....!

Publicado por ramon (2158 intervenciones) el 27/11/2012 21:34:02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{Lo único que aprecio es la falta de internacionalizar  la variable l a 0 en este punto}
 
 
if tec in['s','S'] then
begin
 l := 0;   <----------------------------------------------- a qui
assign(ten,'tempo.tmp');
rewrite(ten);
for i:=0 to filesize(f)-1 do
begin
seek(f,i);
read(f,gente[1]);
if i<>p then
begin
seek(ten,l);
write(ten,gente[1]);
l:=l+1;
end;
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar