Pascal/Turbo Pascal - Ayuda con apareo de archivo

 
Vista:
sin imagen de perfil

Ayuda con apareo de archivo

Publicado por Horacio Daniel Belardita (53 intervenciones) el 26/11/2011 22:03:20
Hola Buenas quisiera si me pueden ayudar con este problema de Apareo de archivos (un registro o ninguno)

* una biblioteca tiene almanecados los datos de sus socios y los prestamos realizados durante el ultimo mes en 2 archivos.Por ej con 10 socios

archivo maestro : un registro por lector

N° LECTOR / NOMBRE Y APELLIDO / DNI / DOMICILIO

archivo de novedades : uno o ningun registro por lector

N° LECTOR / CANTIDAD DE LIBROS DEVUELTOS EN TERMINO / CANTIDAD DE LIBROS DEVUELTOS FUERA DE TERMINO

Se desea obtener un listado de los lectores detallando numero,nombre, cantidad de libros devueltos en termino y cantidad de libros devueltos fuera de termino.
imprimir "*" en un campo de observaciones para aquellos lectores que devolvieron 5 o mas libros fuera de termino y informar el total de prestamos.

Bueno desde ya gracias y saludos
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 apareo de archivo

Publicado por ramon (2158 intervenciones) el 30/11/2011 18:36:08
{Esto servirá}

program apareo2;
uses
crt;
type

maestro = record
n_lector : word;
nombre_apellido : string[50];
dni : string[20];
domicilio : string[30];
end;

novedades = record
n_lector : word;
cldentermino : integer;
cldfdtermino : integer;
marca : char;
end;

const
nombremaestro : string = 'c:\tp\master.dat';
nombrenovedades : string = 'c:\tp\movimi.dat';


var
maest : file of maestro;
noved : file of novedades;
dat1 : maestro;
dat2 : novedades;


procedure entradagatos;
var
tec : char;
begin
clrscr;
repeat
gotoxy(10,2);write('*** Entrada Datos ***');
gotoxy(4,4);write('N§ Lector : ');
gotoxy(24,4);readln(dat1.n_lector);
gotoxy(4,5);write('Nombre y Apellido : ');
gotoxy(24,5);readln(dat1.nombre_apellido);
gotoxy(4,6);write('DNI : ');
gotoxy(24,6);readln(dat1.dni);
gotoxy(4,7);write('Domicilio : ');
gotoxy(24,7);readln(dat1.domicilio);
assign(maest,nombremaestro);
{$I-} reset(maest); {$I+}
if ioresult <> 0 then
begin
rewrite(maest);
seek(maest,0);
write(maest,dat1);
close(maest);
end
else
begin
seek(maest,filesize(maest));
write(maest,dat1);
close(maest);
end;
gotoxy(4,9);write('Desea Entrar Mas [S/N]');
repeat
tec := readkey;
until tec in[#115,#83,#110,#78];
if tec in[#115,#83] then
begin
clrscr;
end;
until tec in[#110,#78];
end;

procedure entradamodi;
var
ppl, tec : char;
cp : longint;
encot : boolean;
begin
clrscr;
repeat
gotoxy(10,2);write('*** Entrada Prestamo ***');
gotoxy(4,4);write('N§ Lector : ');
gotoxy(40,4);readln(dat2.n_lector);
assign(maest,nombremaestro);
{$I-} reset(maest); {$I+}
if ioresult <> 0 then
begin
halt(1);
end;
encot := false;
cp := 0;
repeat
seek(maest,cp);
read(maest,dat1);
if dat2.n_lector = dat1.n_lector then
begin
encot := true;
end;
cp := cp + 1;
until (cp > filesize(maest) - 1) or (encot = true);
close(maest);
if encot = true then
begin
gotoxy(4,5);write('Libros Debueltos Dentro de Plazo [S/N] : ');
gotoxy(45,5);
repeat
ppl := readkey;
until ppl in['s','S','n','N'];
if ppl in['s','S'] then
begin
dat2.cldentermino := dat2.cldentermino + 1;
end;
if ppl in['n','N'] then
begin
dat2.cldfdtermino := dat2.cldfdtermino + 1;
end;
if dat2.cldfdtermino >= 5 then
begin
dat2.marca := '*';
writeln('Total Prestamos : ',(dat2.cldentermino + dat2.cldfdtermino));
end
else
begin
dat2.marca := ' ';
end;
assign(noved,nombrenovedades);
{$I-} reset(noved); {$I+}
if ioresult <> 0 then
begin
rewrite(noved);
seek(noved,0);
write(noved,dat2);
close(noved);
end
else
begin
seek(noved,filesize(noved));
write(noved,dat2);
close(noved);
end;
end
else
begin
clrscr;
gotoxy(10,4);write('El Socio N§ ',dat2.n_lector,' No Existe');
gotoxy(10,7);write('Pulse [Enter]');
readln;
clrscr;
end;
gotoxy(4,9);write('Desea Entrar Mas [S/N]');
repeat
tec := readkey;
until tec in[#115,#83,#110,#78];
if tec in[#115,#83] then
begin
clrscr;
end;
until tec in[#110,#78];

end;

procedure verfichas;
var
paso, cont : longint;
tecl : char;
encont, salir : boolean;
y, ast : integer;
begin
assign(maest,nombremaestro);
{$I-} reset(maest); {$I+}
if ioresult <> 0 then
begin
exit;
end;
assign(noved,nombrenovedades);
{$I-} reset(noved); {$I+}
if ioresult <> 0 then
begin
salir := false;
end
else
begin
salir := true;
end;
cont := 0;
ast := 1;
gotoxy(1,1);write('N§LECTOR NOMBRE Y APELLIDO DEVUELTOS OK NOK OBSERVACION');
y := 3;
repeat
seek(maest,cont);
read(maest,dat1);
gotoxy(2,y);write(dat1.n_lector);
gotoxy(12,y);write(dat1.nombre_apellido);
if salir = true then
begin
paso := 0;
encont := false;
repeat
seek(noved,paso);
read(noved,dat2);
if dat1.n_lector = dat2.n_lector then
encont := true;
paso := paso + 1;
until (paso > filesize(noved) - 1) or (encont = true);
if encont = true then
begin
gotoxy(45,y);write(dat2.cldentermino);
gotoxy(50,y);write(dat2.cldfdtermino);
gotoxy(55,y);write(dat2.marca);
end;
end;
y := y + 1;
ast := ast + 1;
if ast > 32 then
begin
ast := 1;
y := 1;
readln;
clrscr;
end;
cont := cont + 1;
until cont > filesize(maest) - 1;
if salir = true then
close(noved);
close(maest);
readln;
end;



procedure menu;
var
tm : char;
sal : boolean;
begin
sal := false;
repeat
clrscr;
gotoxy(10,2);write('**** Menu Jeneral ****');
gotoxy(5,4);write(' 1 = altas');
gotoxy(5,5);write(' 2 = Prestamos');
gotoxy(5,6);write(' 3 = Ver Fichas');
gotoxy(5,7);write(' 4 = Salir');
gotoxy(10,9);write('<< Elija Opcion >>');
tm := readkey;
clrscr;
case tm of
#49 : entradagatos;
#50 : entradamodi;
#51 : verfichas;
#52 : sal := true;
end;
until sal = true;
end;


begin
clrscr;
menu;
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
sin imagen de perfil

Ayuda con apareo de archivo

Publicado por Horacio Daniel Belardita (53 intervenciones) el 01/12/2011 00:42:19
Una vez mas muchisimas gracias por tu ayuda Ramon.Cuidate y exitos.
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