Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

Ответ
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 29.11.2015, 08:19
nob_keeper nob_keeper вне форума
Прохожий
 
Регистрация: 29.11.2015
Сообщения: 2
Версия Delphi: Delphi 10
Репутация: 10
По умолчанию Ошибка E2066

Компилятор при вызове функции выдаёт ошибку "Отсутствие оператора или точки с запятой". Перепроверил всё, не смог найти причины. Можете помочь?
Код:
procedure Life(StringGrid1:TStringGrid);
var i,j,count:integer;
begin
for i := 0 to StringGrid1.ColCount-1 do
begin
 for j := 0 to StringGrid1.RowCount-1 do
  begin
   count:=Count(StringGrid1,i,j);//ошибка здесь
   if(StringGrid1.Cells[i,j]='0')then
    begin
      if(count=3)then
      StringGrid1.Cells[i,j]:='1';
    end;
    if(StringGrid1.Cells[i,j]='0')then
    begin
      if((count=2)and(count=3))then
      StringGrid1.Cells[i,j]:='1';
    end;
  end;
end;
end;
Вот код функции (реализует подсчёт клеток с содержимым "1" для всех граничных и не граничных клеток(Игра Жизнь):
Код:
function Count(StringGrid1:TStringGrid;i,j:integer):integer;
var count:integer;
begin
//up-left
if ((i=0)and(j=0)) then
   begin
   count:=0;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j+1]='1')then
     count:=count+1;
   end;

//up-medium
 if((i=0)and(j>0)and(j<StringGrid1.RowCount-1))then
 begin
 count:=0;
 if(StringGrid1.Cells[StringGrid1.ColCount-1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j+1]='1')then
     count:=count+1;
 end;

 //up-right
 if((i=0)and(j=StringGrid1.RowCount-1)) then
 begin
 count:=0;
 if(StringGrid1.Cells[StringGrid1.ColCount-1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[StringGrid1.ColCount-1,0]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,0]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,0]='1')then
     count:=count+1;
 end;

 //medium-left
 if((i<>0)and(j=0))then
 begin
 count:=0;
 if(StringGrid1.Cells[i-1,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j+1]='1')then
     count:=count+1;
 end;

 //medium-right
 if((i<>0)and(j=StringGrid1.RowCount-1))then
 begin
 count:=0;
 if(StringGrid1.Cells[i-1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,0]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,0]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,0]='1')then
     count:=count+1;
 end;

 //down-left
 if((i=StringGrid1.ColCount-1)and(j=0))then
 begin
 count:=0;
 if(StringGrid1.Cells[i-1,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,StringGrid1.RowCount-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j+1]='1')then
     count:=count+1;
 end;

 //down-medium
 if((i=StringGrid1.ColCount-1)and(j>0)and(j<StringGrid1.RowCount-1))then
 begin
 count:=0;
 if(StringGrid1.Cells[i-1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j+1]='1')then
     count:=count+1;
 end;

 //down-right
if((i=StringGrid1.ColCount-1)and(j=StringGrid1.RowCount-1))then
 begin
 count:=0;
 if(StringGrid1.Cells[i-1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,0]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,0]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[0,0]='1')then
     count:=count+1;
 end;

//medium
if((i>0)and(i<StringGrid1.ColCount-1)and(j>0)and(j<StringGrid1.RowCount-1))then
 begin
   count:=0;
   if(StringGrid1.Cells[i-1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i-1,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i,j+1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j-1]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j]='1')then
     count:=count+1;
   if(StringGrid1.Cells[i+1,j+1]='1')then
     count:=count+1;
   end;
   Count:=count;
end;
Ответить с цитированием
  #2  
Старый 29.11.2015, 09:11
Аватар для Alegun
Alegun Alegun вне форума
LMD-DML
 
Регистрация: 12.07.2009
Адрес: Богородское
Сообщения: 3,025
Версия Delphi: D7E
Репутация: 1834
По умолчанию

Похоже на совпадение имён - делфи не различает символьный регистр, переименуйте что-то одно из пары переменная-функция Count
Ответить с цитированием
  #3  
Старый 29.11.2015, 09:18
nob_keeper nob_keeper вне форума
Прохожий
 
Регистрация: 29.11.2015
Сообщения: 2
Версия Delphi: Delphi 10
Репутация: 10
По умолчанию

Спасибо большое. С этой проблемой разобрался.
Ответить с цитированием
Ответ


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 17:36.


 

Сайт

Форум

FAQ

RSS лента

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2023

ВКонтакте   Facebook   Twitter