当我写入Pascal中的外部文件时,即使编码完美无缺,外部文件也不会完全写入。
procedure save;
{Menyimpan data penerbangan ke dalam file eksternal}
begin
write('> ');
write('nama file: ');
readln(namafisik);
assign(d,namafisik);
{$I-};
rewrite(d);
{$I+};
if (IOresult=0) then
begin
for i:=1 to Neff do
writejadwal(i);
end;
end;
procedure writejadwal(i:integer);
{Menuliskan jadwal ke file eksternal pada indeks ke-i}
begin
write(d,T.KodePenerbangan[i]);
write(d,' | ');
write(d,T.KotaKeberangkatan[i]);
write(d,' | ');
write(d,T.KotaKedatangan[i]);
write(d,' | ');
if ((T.TKeberangkatan[i].Day) < 10 ) then
begin
x:=T.TKeberangkatan[i].Day;
str(x,y);
s:=y;
write(d,'0'+s);
end
else
begin
write(d,T.TKeberangkatan[i].Day);
end;
write(d,':');
if ((T.TKeberangkatan[i].Month) < 10 ) then
begin
x:=T.TKeberangkatan[i].Month;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKeberangkatan[i].Month);
end;
write(d,':');
write(d,T.TKeberangkatan[i].Year);
write(d,' | ');
if ((T.TKeberangkatan[i].Hour) < 10 ) then
begin
x:=T.TKeberangkatan[i].Hour;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKeberangkatan[i].Hour);
end;
write(d,':');
if ((T.TKeberangkatan[i].Minute) < 10 ) then
begin
x:=T.TKeberangkatan[i].Minute;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKeberangkatan[i].Minute);
end;
write(d,' | ');
if ((T.TKedatangan[i].Day) < 10 ) then
begin
x:=T.TKedatangan[i].Day;
str(x,y);
s:=y;
write(d,'0'+s);
end
else
begin
write(d,T.TKedatangan[i].Day);
end;
write(d,':');
if ((T.TKedatangan[i].Month) < 10 ) then
begin
x:=T.TKedatangan[i].Month;
str(x,y);
s:=y;
write(d,'0'+s);
end
else
begin
write(d,T.TKedatangan[i].Month);
end;
write(d,':');
write(d,T.TKedatangan[i].Year);
write(d,' | ');
if ((T.TKedatangan[i].Hour) < 10 ) then
begin
x:=T.TKedatangan[i].Hour;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKedatangan[i].Hour);
end;
write(d,':');
if ((T.TKedatangan[i].Minute) < 10 ) then
begin
x:=T.TKedatangan[i].Minute;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKedatangan[i].Minute);
end;
write(d,' | ');
if (T.TKedatanganImplementasi[i].Day=0) then
writeln(d,'__:__:____ | __:__ | __:__:____ | __:__')
else
{MULAI}
begin
if ((T.TKeberangkatanImplementasi[i].Day) < 10 ) then
begin
x:=T.TKeberangkatanImplementasi[i].Day;
str(x,y);
s:=y;
write(d,'0'+s);
end
else
begin
write(d,T.TKeberangkatanImplementasi[i].Day);
end;
write(d,':');
if ((T.TKeberangkatanImplementasi[i].Month) < 10 ) then
begin
x:=T.TKeberangkatanImplementasi[i].Month;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKeberangkatanImplementasi[i].Month);
end;
write(d,':');
write(d,T.TKeberangkatanImplementasi[i].Year);
write(d,' | ');
if ((T.TKeberangkatanImplementasi[i].Hour) < 10 ) then
begin
x:=T.TKeberangkatanImplementasi[i].Hour;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKeberangkatanImplementasi[i].Hour);
end;
write(d,':');
if ((T.TKeberangkatanImplementasi[i].Minute) < 10 ) then
begin
x:=T.TKeberangkatanImplementasi[i].Minute;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKeberangkatanImplementasi[i].Minute);
end;
write(d,' | ');
if ((T.TKedatanganImplementasi[i].Day) < 10 ) then
begin
x:=T.TKedatanganImplementasi[i].Day;
str(x,y);
s:=y;
write(d,'0'+s);
end
else
begin
write(d,T.TKedatanganImplementasi[i].Day);
end;
write(d,':');
if ((T.TKedatanganImplementasi[i].Month) < 10 ) then
begin
x:=T.TKedatanganImplementasi[i].Month;
str(x,y);
s:=y;
write(d,'0'+s);
end
else
begin
write(d,T.TKedatanganImplementasi[i].Month);
end;
write(d,':');
write(d,T.TKedatanganImplementasi[i].Year);
write(d,' | ');
if ((T.TKedatanganImplementasi[i].Hour) < 10 ) then
begin
x:=T.TKedatanganImplementasi[i].Hour;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKedatanganImplementasi[i].Hour);
end;
write(d,':');
if ((T.TKedatanganImplementasi[i].Minute) < 10 ) then
begin
x:=T.TKedatanganImplementasi[i].Minute;
str(x,y);
write(d,'0'+y);
end
else
begin
write(d,T.TKedatanganImplementasi[i].Minute);
end;
writeln(d);
end;
{SELESAI}
end;
顺便说一下jadwal是印尼语的英语
答案 0 :(得分:5)
编码并非完美无瑕。特别是,您似乎无法关闭该文件。
答案 1 :(得分:2)
问题在于你没有关闭或冲洗。大多数语言都试图最小化调用OS进行写操作,并且只有在累积了足够的字节时才写入。 (128字节标准,但可以使用settextbuf增加)。可能你的文件是128字节的倍数。
刷新或关闭写出缓冲区的剩余部分。