program svet;
type tovar=record
shapka:string[50] ;
tip:string[10];
name:string[10];
art:string[10];
coast:string[10];
proizv:string[10];
end;
{_____________________________________________________}
var
work_file : file of tovar;
rec : tovar;
file_name : string;
key : integer;
exit : boolean;
x : string;
shapka:string;
srst:real;
{----------------------------------------------------------------------------}
procedure add_record;
begin
writeln('Record N ',filepos(work_file)+1);
with rec do
begin
shapka:= 'і tip tovara і naimenovanie і articul і stoimost і O/P і';
readln(shapka) ;
write('type tovara ');
readln(tip);
write('tovar ');
readln(name);
write('articul ');
readln(art);
write('stoimost ');
readln(coast);
write('obem proizvodstva ');
readln(proizv);
write(work_file,rec);
end;
end;
{_________________________________________________________}
procedure create_new_file;
var
i,n:integer;
begin
write('enter file name');
readln(file_name);
assign(work_file,file_name);
rewrite(work_file);
writeln('Create records of file ',file_name);
write('Enter count records: ');
readln(n);
for i:=1 to n do add_record;
writeln('FILE CREATED');
writeln('File of data have ',filesize(work_file),' records');
close(work_file);
end;
{-----------------------------------------------------------------}
procedure add_records_in_the_end;
begin
write('enter file name');
readln(file_name);
assign(work_file,file_name);
{$I-}
reset(work_file);
{$I+}
if IOresult = 0 then
begin
seek(work_file,filesize(work_file));
add_record;
writeln('Data is wrote. So ',filesize(work_file),' records');
close(work_file);
end
else
writeln('File with name '+file_name+' is not');
end;
{-----------------------------------------------------------------------}
{______________________________________________________________________}
procedure output_record;
begin
read(work_file,rec);
with rec do
begin
write('N ',filepos(work_file),' : ');
writeln('tip: ',tip);
writeln('naimenovanie: ',name);
writeln('articul ',art);
writeln('cena: ',coast);
writeln('o/p: ',proizv)
end;
end;
{----------------------------------------------------------}
procedure output_all_records;
begin
write('enter file name');
readln(file_name);
assign(work_file,file_name);
assign(work_file,file_name);
{$I-}
reset(work_file);
{$I+}
if IOresult = 0 then
begin
seek(work_file,0);
writeln('OUTPUT INFORMATION ABOUT BOOK ','"',file_name,'"');
while (not eof(work_file)) do output_record;
end
else
writeln('File '+file_name+' is not');
end;
{--------------------------------------------------------------------}
procedure update_records;
var
number_of_record:integer;
begin
write('enter file name');
readln(file_name);
assign(work_file,file_name);
{$I-}
reset(work_file);
{$I+}
if IOresult = 0 then
begin
writeln('Enter number of rewrite record :');
readln(number_of_record);
seek(work_file,number_of_record-1);
writeln('Zna4enie of this record: ');
output_record;
seek(work_file,number_of_record-1);
writeln('Enter new zna4enie ',number_of_record,' record');
add_record;
close(work_file);
end
else
writeln('nepvernoe' +file_name);
end;
{-------------------------------------------------------------------------}
begin
exit:=false;
repeat
writeln(' MENU');
writeln('1 - Sozdat" noviy fail');
writeln('2 - prosmotr informacii o tovare');
writeln('3 - Obnovit" zapis');
writeln('4 - dobavit" zapis');
writeln('5 -SOSTAVIT SPISOK');
writeln('6 - EXIT');
write('Your choose: ');
readln(key);
case key of
1:create_new_file;
2:output_all_records;
3: update_records;
4:add_records_in_the_end;
6:exit:=true;
end;
writeln('Executed. <ENTER>');
readln;
until exit;
readln;
end.
end.
repeat
blockread(FileIn,MyRecord,sizeof(MyRecord));
writeln(FileOut,MyRecord.Item1,' ',MyTrcord.Item2,' ',MyRecord.Item3);
until eof(FileIn);
read(FileIn,MyRecord);
uses DOS;Вывод:
procedure GetCurrentDate(var date: DateTime);
var
Year, Month, Day, DayOfWeek: Word;
begin
GetDate(Year, Month, Day, DayOfWeek);
date.Year := Year;
date.Month := Month;
date.Day := Day;
end;
procedure __writer (var f: text; const value: DateTime; w: Integer);
const NameMonth : array[1..12]of string[3] = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
begin
with value do Write(f, Day, '-', NameMonth[Month], '-', Year);
end;
var
date: DateTime;
begin
GetCurrentDate(date);
Writeln('Current Date: ',date);
end.