Ñòóäåíòàì > Êóðñîâûå > ÑÓÁÄ Àâòîñòîÿíêà (íà Ïàñêàëå)
ÑÓÁÄ Àâòîñòîÿíêà (íà Ïàñêàëå)Ñòðàíèöà: 2/3
rewrite(f);
end;
{-----------------------------------------------------------}
procedure Addrecord;
var rez:integer; ch:char;
begin
while rez<>1 do
begin
writeln('Çàäàéòå èìÿ ôàéëà,â
êîòîðûé áóäåò äîáàâëÿòüñÿ çàïèñü');
readln(filename);
assign(f,filename);
reset(f);
rez:=IOResult;
if rez<>0 then
begin
writeln('Ïðîâåðüòå ïðàâèëüíîñòü èìåíè
ôàéëà!');
writeln('Áóäåò ëè ïîâòîðíîå çàäàíèå
èìåíè ôàéëà?(Y/N)');
readln(ch);
if (ch='n') or (ch='N')
then halt (0);
end;
end;
seek(f,filesize(f));
end;
{==========================================================}
procedure Inputfile;
var st:prokat;
k:char;
begin
repeat
writeln('Ââåäèòå äàííûå î íîâîì êëèåíòå : ');
write('Ôàìèëèÿ Õîçÿèíà : '); readln(st.Sname_Hozaina);
write('Èìÿ Õîçÿèíà:' ); readln(st.Name_Hozaina);
write('ìàðêà ìàøèíû:'); readln(st.markauto);
write('ìîäåëü ìàøèíû:'); readln(st.model_auto);
write('òèï êóçîâà:'); readln(st.tip_kyzova);
write('íîìåð ìàøèíû: '); readln(st.Nomer_auto);
write('ðåãèîí:'); readln(st.region);
write('ãîä âûïóñêà: '); readln(st.God_vipyska);
write('öâåò: '); readln(st.color);
write(f,st);
write('Íàäî ëè ââîäèòü äàííûå î íîâîì êëèåíòå ?
(Y/N)>');readln(k);
writeln;
until(k='n') or (k='N');
close(f);
end;
{=========================================================}
procedure redzap;
var
st:prokat;
filename,str:string;
Sname_Hozaina2,Name_Hozaina2:string[15];
markauto2:string[20];
model_auto2:string[20];
tip_kyzova2:string[20];
nomer_auto2:string[20];
region2:integer;
god_vipyska2:integer;
color2:string[20];
x:integer;
begin
writeln('Çàäàéòå èìÿ ôàéëà');
readln(filename);
assign(f,filename);
reset(f);
with st do
begin write('Ââåäèòå ôàìèëèþ
êëèåíòà: ');readln(str);
x:=0;
while not eof(f) do
begin
read(f,st);
if st.Sname_Hozaina=str then
begin
writeln('Ââåäèòå íîâûå äàííûå î êëèåíòå: ');
write('Ôàìèëèÿ õîçÿèíà: '); readln(st.Sname_Hozaina);
write('Èìÿ õîçÿèíà: '); readln(st.Name_Hozaina);
write('ìàðêà ìàøèíû:'); readln(st.markauto);
write('ìîäåëü ìàøèíû:'); readln(st.model_auto);
write('òèï êóçîâà:'); readln(st.tip_kyzova);
write('íîìåð ìàøèíû:'); readln(st.nomer_auto);
write('ðåãèîí:'); readln(st.region);
write('ãîä âûïóñêà:'); readln(st.god_vipyska);
write('öâåò: '); readln(st.color);
Sname_Hozaina2:=Sname_Hozaina;
markauto2:=markauto;
Name_Hozaina2:=Name_Hozaina;
color2:=color;
Nomer_auto2:=Nomer_auto;
model_auto2:=model_auto;
God_vipyska2:=God_vipyska;
tip_kyzova2:=tip_kyzova;
region2:=region;
seek(f,filepos(f)-1);
write(f,st); x:=1;
end; end;
close(f);
end;
if x=0 then begin writeln('Çàïèñè
ñ òàêîé ôàìèëèåé íåò!');readln end;
end;
{==============================================================}
procedure Openfile;
var rez:integer;ch:char;
begin
while rez<>0 do
begin
writeln('Çàäàéòå èìÿ ôàéëà');
readln(filename);
assign(f,filename);
reset(f);
rez:=IOResult;
if rez<>1 then
begin
writeln('Ïðîâåðüòå ïðàâèëüíîñòü èìåíè
ôàéëà!');
writeln('Áóäåò ëè ïîâòîðíîå çàäàíèå
èìåíè ôàéëà ? (Y/N)');
readln(ch);
if (ch='n') or (ch='N')
then halt (0);
end;
end;
end;
{============================================================}
procedure Outputfile;
var st:prokat;k:char;
begin
writeln('Õîòèòå ïîñìîòðåòü äàííûå î êëèåíòàõ ? (Y/N)');
readln(k);
if (k='y') or (k='Y') then
while not eof(f) do
begin
read(f,st); clrscr;
writeln('Ôàìèëèÿ õîçÿèíà:',st.Sname_Hozaina);
writeln('Èìÿ õîçÿèíà:',st.Name_Hozaina);
writeln('ìàðêà ìàøèíû:',st.markauto);
writeln('ìîäåëü ìàøèíû:',st.model_auto);
writeln('òèï êóçîâà:',st.tip_kyzova);
writeln('íîìåð ìàøèíû:',st.nomer_auto);
writeln('ðåãèîí;',st.region);
writeln('ãîä âûïóñêà:',st.god_vipyska);
writeln('öâåò:',st.color);
writeln('Äëÿ ïðîäîëæåíèÿ
íàæìèòå (enter)');
readln;
end;
close(f);
end;
{========================================================}
procedure Clearfile;
var st:prokat;
studtoout:string[20];
fo:file of prokat;
begin
writeln('Çàäàéòå èìÿ ôàéëà,èç êîòîðîãî
óäàëÿþòñÿ ýëåìåíòû');
readln(filename);
assign(f,filename);reset(f);
assign(fo,'newfile.dat');rewrite(fo);
writeln('Çàäàéòå
ôàìèëèþ êëèåíòà, çàïèñü î êîòîðîì óäàëÿåòñÿ');
readln(studtoout);
while not eof(f) do
begin
read(f,st);
if st.sname_Hozaina<>studtoout
then write(fo,st);
end;
close(f);close(fo);
erase(f);
rename(fo,filename);
end;
{ÎÑÍÎÂÍÀß ×ÀÑÒÜ ÏÐÎÃÐÀÌÌÛ}
Begin 11:clrscr;
writeln(' ÌÅÍÞ:');
writeln('1:Ñîçäàíèå ôàéëà');
writeln('2:Äîáàâëåíèå çàïèñè â ôàéë');
writeln('3:Êîððåêòèðîâêà çàïèñè');
writeln('4:Ïðîñìîòð ôàéëà');
writeln('5:Óäàëåíèå çàïèñè èç ôàéëà');
writeln('6:Âûõîä èç ïðîãðàììû');
readln(k);
case k of 1: begin Creatfile; Inputfile
end;
2: begin Addrecord; Inputfile
end;
3: redzap;
4: begin Openfile; Outputfile
end;
5: Clearfile;
6: Halt;
else writeln('Îøèáêà.Ïîâòîðèòå íîìåð
ðåæèìà.')
|