UTNianos

Versión completa: Como catso hago un apareo en pascal?
Actualmente estas viendo una versión simplificada de nuestro contenido. Ver la versión completa con el formato correcto.
Páginas: 1 2
Hice la lectura especial, hago el ciclo, hago todo pero pascal me tira error 100 o me copia las cosas por la mitad.

La verdad ya no entiendo que tengo que hacer.


program leeguarda;


uses

Crt;

type
str5 = string[5];
str4 = string[4];
rZona = record
NroPat: str4;
NroRegCond: integer;
rFecInf:record
dd,
mm: byte;
aaaa: word;
CodDestPol,
CodInfr: word;
NroIdPol: str5;
end;
end;
ArcTipo = file of rZona;


var
fda,fdb : boolean;
zna,
znb,
aux: ArcTipo;
registro,
registro2: rZona;
fechA,fechB: integer;
begin
Filemode :=0;
assign (zna, 'ZONA1.dat');
reset (zna);
assign (znb, 'ZONA2.dat');
reset(znb);
assign (aux,'AUXILIAR1.dat');
rewrite(aux);
{seek(zna,0);
seek(znb,0);
seek(aux,0);}

fda := false;
fdb := false;
if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;

while not fda and not fdb do begin



end;

while not fda do begin
read(zna,registro);
write(aux,registro);
end;
while not fdb do begin
read(znb,registro2);
write(aux,registro2);
end;

close (zna);
close (znb);
close (aux);


{
while not eof (zna) and not eof (znb) do begin
read(zna,registro);
read(znb,registro2);
write(aux,registro,registro2);
end;}

end.

dentro del while iria todo lo relacinoado con copiar pegar leer etc etc


pero no lo pongo porqeu cuadno lo pongo no funciona tira error 100, que leo afuera de los limites
del archivo.
no te dice en que linea te tira el error ?
No tira error de sintaxis, osea salta un error 100 y no se que hago mal.
creo que puede ser por esto:


Cita:while not fda do begin
read(zna,registro);
write(aux,registro);
end;
while not fdb do begin
read(znb,registro2);
write(aux,registro2);
end;

close (zna);
close (znb);
close (aux);

(puse los close asi sabes en que parte hablo).

vos validas el fda y fdb arriba y lees..... y despues volves a leer en esa parte, pero no actualizas fda y fdb, entonces ahi podria suceder que tratas de leer y llegaste al eof y te tira el error 100
El tema es que esas lecturas las vuelvo a hacer dentro del ciclo while. (que eso no te lo puse en el codigo)
sin el codigo no puedo adivinar =P

pone todo el codigo y usuando el coso de "codigo" asi queda mas lindo y se ve mejor
program leeguarda;


uses

Crt;

type
str5 = string[5];
str4 = string[4];
rZona = record
NroPat: str4;
NroRegCond: integer;
rFecInf:record
dd,
mm: byte;
aaaa: word;
CodDestPol,
CodInfr: word;
NroIdPol: str5;
end;
end;
ArcTipo = file of rZona;


var
fda,fdb : boolean;
zna,
znb,
aux: ArcTipo;
registro,
registro2: rZona;
fechA,fechB: integer;
begin
Filemode :=0;
assign (zna, 'ZONA1.dat');
reset (zna);
assign (znb, 'ZONA2.dat');
reset(znb);
assign (aux,'AUXILIAR1.dat');
rewrite(aux);


if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;

while not fda and not fdb do begin
write (zna, registro);
write (znb, registro2);

if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;





end;

while not fda do begin
read(zna,registro);
write(aux,registro);
end;
while not fdb do begin
read(znb,registro2);
write(aux,registro2);
end;

close (zna);
close (znb);
close (aux);


end.

program leeguarda;


uses

Crt;

type
str5 = string[5];
str4 = string[4];
rZona = record
NroPat: str4;
NroRegCond: integer;
rFecInf:record
dd,
mm: byte;
aaaa: word;
CodDestPol,
CodInfr: word;
NroIdPol: str5;
end;
end;
ArcTipo = file of rZona;


var
fda,fdb : boolean;
zna,
znb,
aux: ArcTipo;
registro,
registro2: rZona;
fechA,fechB: integer;
begin
Filemode :=0;
assign (zna, 'ZONA1.dat');
reset (zna);
assign (znb, 'ZONA2.dat');
reset(znb);
assign (aux,'AUXILIAR1.dat');
rewrite(aux);


if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;

while not fda and not fdb do begin
write (zna, registro);
write (znb, registro2);

if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;





end;

while not fda do begin
read(zna,registro);
write(aux,registro);
end;
while not fdb do begin
read(znb,registro2);
write(aux,registro2);
end;

close (zna);
close (znb);
close (aux);


end.


emmmm, no, fijate que en el ultimo while nunca cambias el valor de fda y fdb

program leeguarda;


uses

Crt;

type
str5 = string[5];
str4 = string[4];
rZona = record
NroPat: str4;
NroRegCond: integer;
rFecInf:record
dd,
mm: byte;
aaaa: word;
CodDestPol,
CodInfr: word;
NroIdPol: str5;
end;
end;
ArcTipo = file of rZona;


var
fda,fdb : boolean;
zna,
znb,
aux: ArcTipo;
registro,
registro2: rZona;
fechA,fechB: integer;
begin
Filemode :=0;
assign (zna, 'ZONA1.dat');
reset (zna);
assign (znb, 'ZONA2.dat');
reset(znb);
assign (aux,'AUXILIAR1.dat');
rewrite(aux);


if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;

while not fda and not fdb do begin
write (zna, registro);
write (znb, registro2);

if not eof(zna) then begin
read(zna,registro);
fda := false;
end else begin
fda := true;
end;
if not eof(znb) then begin
read(znb,registro2);
fdb := false;
end else begin
fdb := true;
end;





end;

while not fda do begin
read(zna,registro);
write(aux,registro);
end;
while not fdb do begin
read(znb,registro2);
write(aux,registro2);
end;

close (zna);
close (znb);
close (aux);


end.

Pero esos while son una vez que salieron del primer ciclo para vaciar los archivos luego del apareo.
por eso mismo


estas haciendo read de algo que puede ser un eof, y por eso te tira error.


o sea, cuando llegas al final, como no validas que no sea eof, lee eof y rompe

haceme caso, valida eso y vas a ver que anda
disculpame estoy quemado, como lo puedo validar? Que parte?
linea 80 a 87


pregunta si es eof y actuliza los flag
Pruebo y te digo, gracias. Disculpá la molestia.
Sale error 105, ahora lo arreglo.
mira que si queres leer y llegaste al eof, le tenes que hacer un reset o un seek a la posicion 0

creeeo
PERFECTO!!!!!!! SOS UN GENIO!!!. CUCHAME, hago apareo de dos archivos que pesan 1,14 kb y 1,43 kb, pero el archivo final pesa 2,55 kb. Puede que haya un error de copia? No me faltaran los ultimos registros?
Páginas: 1 2
URLs de referencia