Pregunta: | 67774 - ELIMINAR REGISTRO |
Autor: | Anie Orozco |
a este programa le tengo que agregar un procedure para eliminar registros , he investigado y no encuentro nada, me podrían dar una opción para terminarlo y me podrían explicar ¿que son nodos? program DemoAdirecto; type xr = record nombre : string [20]; edad : integer; end; var reg :xr; archivo: file of xr; opc : byte; procedure crea; {crea e inicializa en disco el archivo de datos con que trabajara el programa} begin assign(archivo, 'K:cejemplo.text'); rewrite(archivo); close(archivo); end; procedure altas; {añade registros a al archivo de datos} begin assign(archivo,'K:cejemplo.text'); reset(archivo); while not eof (archivo) do read(archivo,reg); with reg do begin write('nombre'); readln (nombre); write('edad'); readln(edad); end; write(archivo,reg); close(archivo); end; procedure consultas; {realiza una consulta de datos por numero de registro} var nreg : byte; begin assign (archivo, 'K:cejemplo.text'); reset(archivo); {tam:=filesize(archivo):} writeln('numero de registro a consultar:'); readln(nreg); seek(archivo,nreg-1); read(archivo,reg); with reg do begin writeln('nombre', nombre); writeln('edad ', edad); end; writeln('teclazo...'); readln; close (archivo); end; procedure connom; {realiza una consulta de datos, realizando una busqueda secuencial por nombre} var nbus : string[20]; ban : byte; begin assign(archivo ,'K:cejemplo.text'); reset(archivo); write('teclea el nombre a buscar'); readln (nbus); {tam := filesize(archivo);} ban := 0; while not eof (archivo) do begin read(archivo, reg); if reg.nombre = nbus then begin writeln('la edad de ',nbus,' es ', reg.edad); ban := 1; end; end; if ban = 0 then writeln('lo siento, el nombre no se encontro'); writeln('teclazo...'); readln; close(archivo); end; procedure reppan; {despliga en la pantalla el cotenido del archivo de datos} begin assign (archivo,'K:cejemplo.text'); reset(archivo); while not eof (archivo) do begin read(archivo,reg); writeln('nombre => ', reg.nombre,' edad =>', reg.edad); end; writeln; writeln('teclazo...'); readln; close(archivo); end; procedure modif; var nreg : byte; begin assign(archivo , 'K:cejemplo.text'); reset(archivo); {tam:= filesize (archivo);} writeln('numero de registro a consultar:'); readln (nreg); seek (archivo,nreg-1); read(archivo,reg); with reg do begin writeln('los datos actuales son:'); writeln('nombre ', nombre); writeln('edad ', edad); writeln('ahora teclea los nuevos datos:'); writeln('nombre'); readln(nombre); writeln('edad '); readln(edad); seek (archivo,nreg-1); write(archivo,reg); end; writeln('teclazo...'); readln; close(archivo); end; begin opc:=0; repeat writeln('opciones'); writeln('1.-crear'); writeln('2.-altas'); writeln('3.-consultas por no. de registro'); writeln('4.-consultas por nombre'); writeln('5.-reporte por pantalla'); writeln('6.- modificar datos por nombre'); writeln('7.-salir'); writeln('teclea tu opcion ==> '); readln(opc); case opc of 1: crea; 2: altas; 3: consultas; 4: connom; 5: reppan; 6 : modif; end; until (opc=7); end. |