|
#1
|
|||
|
|||
Ошибка 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; Код:
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
|
||||
|
||||
Похоже на совпадение имён - делфи не различает символьный регистр, переименуйте что-то одно из пары переменная-функция Count
Я не понял Вашего вопроса, но всё же Вам на него отвечу! |
#3
|
|||
|
|||
Спасибо большое. С этой проблемой разобрался.
|