Pascal/Turbo Pascal - ayuda con procedimiento para eliminar registro

 
Vista:

ayuda con procedimiento para eliminar registro

Publicado por Nata (1 intervención) el 15/07/2014 23:39:09
Buenas tardes a todos. Agradeceria mucho su ayuda. Hice un procedimiento para eliminar un registro de un archivo. Busco el numero de empleado y lo elimina. Pero si lo vuelvo a buscar dice q lo vuelve a eliminar. Por q si el registro no existe? Lo verifico al consultar y no esta. Me pueden ayudar a verificar mi codigo de eliminacion?

Gracias de antemano

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
procedure eliminar(numempleado : longint);
 
var
a : longint;
opcion:char;
begin
assign(f,bd);
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
writeln(' Error Archivo No Encontrado Pulse Una Tecla');
readkey;
end
else
begin
for apun := 0 to filesize(f) - 1 do
begin
seek(f,a);
read(f,datosE);
if datosE.NumEmpleado <> numempleado then
begin
end
else
begin
writeln('Esta seguro ? S/N');
readln(opcion);
if (opcion = 'S')  then
begin
datosE.estatus := false;
seek(f,a);
write(f,datosE);
writeln ('Empleado eliminado');
readkey;
end;
end;
end;
close(f);
end;
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

ayuda con procedimiento para eliminar registro

Publicado por ramon (39 intervenciones) el 17/07/2014 00:34:03
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
{Mira a  ver si esto te sirve}
 
procedure eliminar(numempleado : longint);
var
  a : longint;
  opcion : char;
begin
  assign(f,bd);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
      writeln(' Error Archivo No Encontrado Pulse Una Tecla');
      readkey;
    end
 else
   begin
    for a := 0 to filesize(f) - 1 do
    begin
      seek(f,a);
      read(f,datosE);
  if (datosE.NumEmpleado = numempleado) and (datose.estatus = true) then
   begin
      writeln('Esta seguro ? S/N');
      readln(opcion);
   if (upcase(opcion) = 'S') then
   begin
     datosE.estatus := false;
     seek(f,a);
     write(f,datosE);
     writeln ('Empleado eliminado');
     readkey;
     break;
   end;
 end
else
  begin
  end;
 end;
  close(f);
 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