Форум программистов, компьютерный форум, киберфорум
Free Pascal
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
0 / 0 / 1
Регистрация: 22.12.2011
Сообщений: 25
1

Ошибка Runtime Error 5. Не могу найти где.

25.01.2012, 15:01. Показов 2253. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
{модуль}
unit Modul;

INTERFACE
uses crt;
TYPE
Baza = record
Firm, NameTea: string [50];
Color, Category, PriceTea: string;
end;

VAR
F: File of baza;
G: File of baza;
i,j,r,k: integer;
data,vr: Baza;
Z: array [1..50] of baza;
n,a,m: string;

Procedure Menu;
Procedure Output;
Procedure Add;
Procedure Delete;
Procedure Edit;
Procedure SortPrice;
Procedure SortNameTea;
Procedure Sort;
Procedure SearchNameTea;
Procedure SearchPriceTea;
Procedure Search;


IMPLEMENTATION

{Процедура меню}

Procedure Menu;
begin
clrscr;
writeln(' Database <<<Tea>>> ');
writeln('');
writeln('');
writeln('');
writeln(' MAIN MENU');
writeln(' 1. See');
writeln(' 2. Add');
writeln(' 3. Delete');
writeln(' 4. Edit');
writeln(' 5. Search');
writeln(' 6. Sort');
writeln(' 0. Exit');
write;
end;

Function CheckTheFile: boolean;
begin
clrscr;
{$I-}
Assign(F, 'tovar.txt');
Reset(F);
{$I+}
if IOResult<>0 then
begin
Close(F);
Rewrite(F);
clrscr;
Write('The database file is not found.');
Close(F);
Exit;
end
else
begin
if FileSize(F)=0 then
begin
Write('The file is empty');
Close(F);
CheckTheFile := true;
Exit;
end;
end;
end;

{Процедура вывода базы данных}

Procedure Output;
begin
clrscr;
if not CheckTheFile then
begin
Assign(F, 'tovar.txt');
Reset(F);
Writeln('*','№':3,'|', 'Name Tea':15,'|', 'Firm':9,'|', 'Color':7,'|', 'Category':8,'|', 'PriceTea':5,'*':3);
Writeln('----------------------------------------------------------------------------');
i:=0;
while not EOF(F) do
begin
Read(F, data);
Writeln('*',i:3,'|', data.NameTea:15,'|', data.Firm:9,'|', data.Color:7,'|', data.Category:8,'|',data.PriceTea:5,'*':3);
i:=i+1;
end;
end;
Close(F);
end;

{Прцедура добавления}

Procedure Add;
VAR
o:integer;
begin
clrscr;
write('Enter the number of entries to add:');
readln(o);
for i:=1 to o do
begin
Write('Enter the name of tea: ');
Readln(data.NameTea);
Write('Enter the manufacturer: ');
Readln(data.Firm);
Write('Enter the color of tea: ');
Readln(data.Color);
Write('Enter the category of tea: ');
Readln(data.Category);
Write('Enter the price: ');
Readln(data.PriceTea);

{$I-}
Assign(F, 'tovar.txt');
Reset(F);
{$I+}
if IOResult<>0 then
begin
Close(F);
Rewrite(F);
end
else
begin
Close(F);
Reset(F);
Seek(F, FileSize(F));
Write(F, data);
end;
end;
Close(F);
end;

{Процедура удаления}

Procedure Delete;
VAR
del: integer;
begin
if not CheckTheFile then
begin
Assign(F, 'tovar.txt');
Reset(F);
Output;
Writeln;Writeln;
Write('Enter the number of deleted records: ');
Readln(del);
Assign(G, '~temp~');
Rewrite(G);
{$I-}
Reset(F);
{$I+}
i:=0;
while not EOF(F) do
begin
Read(F, data);
if i<>del then Write(G, data);
i:=i+1;
end;
Close(F);
Erase(F);
Close(G);
ReName(G, 'tovar.txt');
end;
end;

{Процедура редактирования}

procedure Edit;
VAR
ed: integer;
begin
if not CheckTheFile then
begin
Assign(F, 'tovar.txt');
Reset(F);
Output;
Writeln;Writeln;
Write('Enter the number of records being edited:');
Readln(ed);
Reset(F);
Seek(F, ed);
Read(F, data);
Writeln;
Write(data.NameTea, ' -> ');
Readln(data.NameTea);
Write(data.Firm, ' -> ');
Readln(data.Firm);
Write(data.Color, ' -> ');
Readln(data.Color);
Write(data.Category, ' -> ');
Readln(data.Category);
Write(data.PriceTea, ' -> ');
Readln(data.PriceTea);
Seek(F, ed);
Write(F, data);
Close(F);
end;
end;

{Сортировка по цене}

Procedure SortPrice;
begin
assign(f,'tovar.txt');
reset(f);
i:=0;
while not eof(f) do
begin
i:=i+1;
j:=i;
read(f,z[i]);
end;
Close(F);
rewrite(f);
for i:=1 to j do
begin
for j:=1 to j do
begin
if z[i].PriceTea < z[j].PriceTea then
begin
vr:=z[i];
z[i]:=z[j];
z[j]:=vr;
end;
end;
end;
for i:=1 to j do
write(F,z[i]);
close(F);
Output;
write('Sorting Completed');
readln;
end;

{Сортировка по наименованию}

Procedure SortNameTea;
begin
assign(f,'tovar.txt');
reset(f);
i:=0;
while not eof(f) do
begin
i:=i+1;
j:=i;
read(f,z[i]);
end;
Close(F);
rewrite(f);
for i:=1 to j do
begin
for j:=1 to j do
begin
if z[i].NameTea < z[j].NameTea then
begin
vr:=z[i];
z[i]:=z[j];
z[j]:=vr;
end;
end;
end;
for i:=1 to j do
write(F,z[i]);
close(F);
Output;
write('Sorting Completed');
readln;
end;

{Процедура сортировки}

Procedure Sort;
begin
if not CheckTheFile then
begin
Assign(F, 'tovar.txt');
Reset(F);
Writeln('Enter the collation');
Writeln('1-Name Tea');
Writeln('2-Price Tea');

Readln(n);
clrscr;
Close(F);
if (n='1') then SortNameTea;
if (n='2') then SortPrice;
end;
end;

{Процедура поиска по наименованию}

Procedure SearchNameTea;
begin
k:=0;
j:=1;
r:=1;
assign(F, 'tovar.txt');
reset(F);
while not eof(F) do
begin
read(F,z[j]);
j:=j+1;
end;
close(F);
write('Enter the name of tea =>');
readln(n);
clrscr;
writeln;
writeln('Search results: ');
Writeln('*','№':3,'|', 'Name Tea':15,'|', 'Firm':9,'|', 'Color':7,'|', 'Category':8,'|', 'Price Tea':5,'*':3);
Writeln('----------------------------------------------------------------------------');
Reset(F);
for i:=1 to FileSize(F) do
begin
if n=z[i].NameTea then
begin
k:=1;
data.NameTea:=n;
data.Firm:=z[i].Firm;
data.Color:=z[i].Color;
data.Category:=z[i].Category;
data.PriceTea:=z[i].PriceTea;
write('*',r:2,'*');
write(' ',data.NameTea:15,'*');
write(' ',data.Firm:8,'*');
write(' ',data.Color:6,'*');
writeln(' ',data.Category:8,'*');
writeln(' ',data.PriceTea:5,'*');
r:=r+1;
end;
end;
Close(F);
writeln('*----------------------------------------------------------------------------*');
if k=0 then
begin
clrscr;
write('Data not found');
readln;
end;
readln;
end;

{Поиск по цене}

Procedure SearchPriceTea;
begin
k:=0;
j:=1;
r:=1;
assign(F,'tovar.txt');
reset(F);
while not eof(F) do
begin
read(F,z[j]);
j:=j+1;
end;
close(F);
write('Enter a minimum price of tea =>');
readln(m);
write('Enter a maximum price of tea =>');
readln(a);
clrscr;
writeln;
writeln('Search results: ');
Writeln('*','№':3,'|', 'Name Tea':15,'|', 'Firm':9,'|', 'Color':7,'|', 'Category':8,'|', 'Price Tea':5,'*':3);
Writeln('----------------------------------------------------------------------------');
for i:=1 to FileSize(F) do
begin
if (m<z[i].PriceTea)and(a>z[i].PriceTea) then
begin
k:=1;
data.PriceTea:=z[i].PriceTea;
data.NameTea:=z[i].NameTea;
data.Firm:=z[i].Firm;
data.Color:=z[i].Color;
data.Category:=z[i].Category;
write('*',r:2,' *');
write(' ',data.NameTea:15,' *');
write(' ',data.Firm:8,' *' );
write(' ',data.Color:6,' *');
write(' ',data.Category:8,' *');
writeln(' ',data.PriceTea:5,' *');
r:=r+1;
end;
end;
writeln('*----------------------------------------------------------------------------*');
if k=0 then
begin
clrscr;
write('Data not found');
readln;
end;
readln;
end;

{Процедура поиска}

Procedure Search;
begin
clrscr;
Writeln('Enter your search option');
Writeln('Search for:');
Writeln('1-Name Tea');
Writeln('2-Price Tea');
Readln(n);
clrscr;
if (n='1') then SearchNameTea;
if (n='2') then SearchPriceTea;
end;
END.

{основная программа}
program BD_Tea;
uses crt, Modul;
VAR
key : char;
name: string;

begin
clrscr;
name:='Tovar.txt';
{Основное меню: }
repeat
Menu;
writeln('Enter the item number');
key:=readkey;
case key of
'1':
begin
Output;
readkey;
end;
'2': Add;
'3': Delete;
'4': Edit;
'5': Search;
'6': Sort;
'0':
begin
Exit;
end;
end;
until (key='0');
readkey;
end.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
25.01.2012, 15:01
Ответы с готовыми решениями:

Runtime error не пойму где ошибка
Здравствуйте, в этом компиляторе onlinegdb.com код работает, но если указать значения...

Ошибка Microsoft Visual C++ Runtime Library - Runtime Error
Здравствуйте. Буду признательна за помощь в моей беде. Совсем в этом не разбираюсь. В Safari при...

Ошибка времени исполнения: Server Error in '/' Application, Runtime Error
Здравствуйте, через некоторое время после загрузки страницы если нажимаю на кнопку, то выдает...

Error: lvalue required as left operand of assignment. Не могу разобраться где ошибка
#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main() { int n, count = 0; for (n = 111; n...

0
25.01.2012, 15:01
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
25.01.2012, 15:01
Помогаю со студенческими работами здесь

Не могу разобраться где ошибка!error LNK2019: ссылка на неразрешенный внешний символ
#include &quot;stdafx.h&quot; #include &quot;conio.h&quot; #include &quot;stdio.h&quot; #include &quot;stdlib.h&quot; #include...

Ошибка Runtime Error (RE)
Приветствую! Решил пару задач на python. Рассмотрел все варианты. Все работает как нужно, но...

Ошибка Runtime Error
Здраствуйте, такая проблема, при попытке запустить установочный файл игры (Setup.exe) возникает...

Ошибка Runtime Error 94
Всем привет! делаю лабу в access смысл такой что нажимаю на кнопку и она должна выполнить вот...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru