| Autor |
Beitrag |
Tisa
Hält's aus hier
Beiträge: 1
|
Verfasst: Do 19.01.06 20:37
Hallo!
Erst mal ein großes Lob. Dieses Forum finde ich richtig spitze.
Jetzt zu meinem Problem.
Kann mir jemand sagen, wie ich den unten stehenden Quelltextauszug sinnvoll zusammenfassen kann?
Die Programierung ist noch nicht vollständig, aber jetzt schon super lang.
Würde mich freuen wenn ihr mir helft
Tisa
Quelltext:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74:
| ........ procedure TForm1.BnSuchenClick(Sender: TObject); var x,y,a:integer; Suchwort:string; begin Suchwort:=Edit1.Text; for y:=1 to feld.RowCount -1 do begin for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x+1,y] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x-1,y] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x,y-1] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x,y+1] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x+1,y+1] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x-1,y+1] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x+1,y-1] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end;
for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x-1,y-1] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end; end; end; ............. |
|
|
UGrohne
      

Beiträge: 5502
Erhaltene Danke: 220
Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
|
Verfasst: Do 19.01.06 20:55
Erstmal ganz easy:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
| ........ procedure TForm1.BnSuchenClick(Sender: TObject); var x,y,a:integer; Suchwort:string; i1,i2,i: integer; begin Suchwort:=Edit1.Text; for y:=1 to feld.RowCount -1 do begin for i:= 0 to 7 do begin case i of 0: i1:=1; i2:=0; 1: i1:=-1; i2:=0; 2: i1:=0; i2:=1; 3: i1:=0; i2:=-1; 4: i1:=1; i2:=1; 5: i1:=-1; i2:=1; 6: i1:=1; i2:=-1; 7: i1:=-1; i2:=-1; end; for x:=feld.FixedCols to feld.colcount -1 do begin for a:=1 to Length(Suchwort) do if feld.Cells[x,y] = Suchwort[1] then if feld.Cells[x+i1,y+i2] = Suchwort[2] then feld.Cells[x,y]:=lowercase(feld.Cells[x,y]); end; end; end; end; |
Gibt bestimmt noch ne Vereinfachung 
|
|
GTA-Place
      

Beiträge: 5248
Erhaltene Danke: 2
WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
|
Verfasst: Do 19.01.06 21:01
Ich denk so:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| var x, y, a: Integer; Suchwort: String; begin Suchwort := Edit1.Text;
for y := 1 to feld.RowCount - 1 do begin for x:= feld.FixedCols to feld.colcount - 1 do begin for a := 1 to Length(Suchwort) do if (feld.Cells[x,y] = Suchwort[1]) AND ((feld.Cells[x + 1, y] = Suchwort[2]) OR (feld.Cells[x - 1, y] = Suchwort[2]) OR (feld.Cells[x, y - 1] = Suchwort[2]) OR (feld.Cells[x, y + 1] = Suchwort[2]) OR (feld.Cells[x + 1, y + 1] = Suchwort[2]) OR (feld.Cells[x - 1, y + 1] = Suchwort[2]) OR (feld.Cells[x + 1, y - 1] = Suchwort[2]) OR (feld.Cells[x - 1, y - 1] = Suchwort[2])) then feld.Cells[x, y] := LowerCase(feld.Cells[x,y]); end; end; |
_________________ "Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
|
|
|