Тема: Ошибка E2066
Показать сообщение отдельно
  #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;
Ответить с цитированием