Archivos con tipo
Publicado por Leandro (3 intervenciones) el 10/11/2007 22:36:47
Olas bue trate de hacer un programa que genere un archivo tipo .dat que tenga los datos de como le ha hido a un alumno atravez del año sabiendo si ha sido eximido enviado a diciembre o marzo...
les paso el codigo asi lo ven me tira un error en las lineas donde leo los campos del registro...
en una parte del programa aclaro la linea entre {}...
desde ya muchas gracias!
uses crt;
type
alumno=record
dni:longint; eximido:boolean;
diciembre:boolean; marzo:boolean;
end;
var
aux:alumno; arch:file of alumno;
op,e,d,m,pri,seg,ter:integer; prom:real;
BEGIN assign(arch,'c:\notas.dat');
e:=0; d:=0; m:=0;
repeat clrscr;
reset(arch);
writeln('Ingrese la opcion deseada: ');
writeln('1)Agregar datos: ');
writeln('2)Ver eximidos: ');
writeln('3)Ver a Diciembre: ');
writeln('4)Ver a Marzo: ');
writeln('5)Generar archivo: ');
writeln('0)Salir');
readln(op);
if op=1 then
begin clrscr;
reset(arch);writeln('Ingrese el DNI: ');
readln(aux.dni);
writeln('Ingrese la primer nota: ');
readln(pri);
writeln('Ingrese la segunda nota: ');
readln(seg);
writeln('Ingrese la tercer nota: ');
readln(ter);
prom:=(pri+seg+ter)/3;
if prom>=18 then
begin
if pri<6 then
aux.diciembre:=true
else
aux.eximido:=true;
end;
if (prom>=4) and (prom<6) then
aux.diciembre:=true;
if (prom>4) then
aux.marzo:=true;
write(arch,aux);
close(arch);
end;
if op=2 then
begin clrscr;
reset(arch);
while not eof(arch) do
begin
if aux.eximido=true then
e:=e+1;
end;
writeln('Los eximidos fueron: ',e);
close(arch);
end;
if op=3 then
begin clrscr;
reset(arch);
while not eof(arch) do
begin
if aux.diciembre=true then {cuando lo compilo y elijo esta opcion no hace nada y queda la linea en verde}
d:=d+1;
end;
writeln('Los que se fueron a diciembre son: ',d);
close(arch);
end;
if op=4 then
begin
reset(arch);
while not eof(arch) do
begin
if aux.marzo=true then
m:=m+1;
end;
writeln('Los que se fueron a marzo son: ',m);
close(arch);
end;
if op=5 then
begin clrscr;
rewrite(arch);
close(arch);
writeln('Archivo generado ',chr(2))
end;
until op=0;
END.
les paso el codigo asi lo ven me tira un error en las lineas donde leo los campos del registro...
en una parte del programa aclaro la linea entre {}...
desde ya muchas gracias!
uses crt;
type
alumno=record
dni:longint; eximido:boolean;
diciembre:boolean; marzo:boolean;
end;
var
aux:alumno; arch:file of alumno;
op,e,d,m,pri,seg,ter:integer; prom:real;
BEGIN assign(arch,'c:\notas.dat');
e:=0; d:=0; m:=0;
repeat clrscr;
reset(arch);
writeln('Ingrese la opcion deseada: ');
writeln('1)Agregar datos: ');
writeln('2)Ver eximidos: ');
writeln('3)Ver a Diciembre: ');
writeln('4)Ver a Marzo: ');
writeln('5)Generar archivo: ');
writeln('0)Salir');
readln(op);
if op=1 then
begin clrscr;
reset(arch);writeln('Ingrese el DNI: ');
readln(aux.dni);
writeln('Ingrese la primer nota: ');
readln(pri);
writeln('Ingrese la segunda nota: ');
readln(seg);
writeln('Ingrese la tercer nota: ');
readln(ter);
prom:=(pri+seg+ter)/3;
if prom>=18 then
begin
if pri<6 then
aux.diciembre:=true
else
aux.eximido:=true;
end;
if (prom>=4) and (prom<6) then
aux.diciembre:=true;
if (prom>4) then
aux.marzo:=true;
write(arch,aux);
close(arch);
end;
if op=2 then
begin clrscr;
reset(arch);
while not eof(arch) do
begin
if aux.eximido=true then
e:=e+1;
end;
writeln('Los eximidos fueron: ',e);
close(arch);
end;
if op=3 then
begin clrscr;
reset(arch);
while not eof(arch) do
begin
if aux.diciembre=true then {cuando lo compilo y elijo esta opcion no hace nada y queda la linea en verde}
d:=d+1;
end;
writeln('Los que se fueron a diciembre son: ',d);
close(arch);
end;
if op=4 then
begin
reset(arch);
while not eof(arch) do
begin
if aux.marzo=true then
m:=m+1;
end;
writeln('Los que se fueron a marzo son: ',m);
close(arch);
end;
if op=5 then
begin clrscr;
rewrite(arch);
close(arch);
writeln('Archivo generado ',chr(2))
end;
until op=0;
END.
Valora esta pregunta


0