📄 typedfil.pas
字号:
{ A crude database recording }
uses crt;
type
Temployee = record
name : string[20];
address : string[40];
phone : string[15];
age : byte;
salary : longint;
end;
var
F : file of Temployee;
c : char;
r : Temployee;
s : string;
n : integer;
begin
clrscr;
write('Input file name to record databases : '); readln(s);
assign(F,s); { Associate it }
{$I-}
reset(F); { First, open it }
{$I+}
n:=IOResult;
if n<>0 then { If it's doesn't exist then }
begin
{$I-}
rewrite(F); { Create it }
{$I+}
n:=IOResult;
if n<>0 then
begin
writeln('Error creating file !'); halt;
end;
end
else
begin { If it exists then }
n:=filesize(F); { Calculate total record }
seek(F,n); { Move file pointer PAST the last record }
end;
repeat
clrscr;
writeln('File position : ',filepos(f));
write('Name = '); readln(r.name); { Input data }
write('Address = '); readln(r.address);
write('Phone = '); readln(r.phone);
write('Age = '); readln(r.age);
write('Salary = '); readln(r.salary);
write(F,r); { Write data to file }
write('Input data again (Y/N) ?');
repeat
c:=upcase(readkey); { Ask user : Input again or not }
until c in ['Y','N'];
writeln(c);
until c='N';
close(F);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -