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: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106:
| [...] procedure Tform1.MixDuplicates(NewCell1, NewCell2: String); var strExistingCell1, strExistingCell2 : String; arrstrExistingWords1, arrstrExistingWords2, arrstrNewWords1, arrstrNewWords2 : Array of String; intRowCounter, intWordNumber, intCounter1, intCounter2 : Integer; begin intRowCounter := 0; for intRowCounter to ClientDataSet.RecordCount do begin
strExistingCell1 := ClientDataSet.FieldByName('Spalte1').AsString; strExistingCell2 := ClientDataSet.FieldByName('Spalte2').AsString;
intWordNumber := 0; while not (Length(strExistingCell1) = 0) do begin arrstrExistingWords1[intWordNumber] := Copy(strExistingCell1,1,(Pos(',',strExistingCell1)-1)); Delete(strExistingCell1,1,Pos(',',strExistingCell1); intWordNumber := intWordNumber+1 end;
intWordNumber := 0; while not (Length(strExistingCell2) = 0) do begin arrstrExistingWords2[intWordNumber] := Copy(strExistingCell2,1,(Pos(',',strExistingCell2)-1)); Delete(strExistingCell2,1,Pos(',',strExistingCell2); intWordNumber := intWordNumber+1 end;
intWordNumber := 0; while not (Length(strNewCell1) = 0) do begin arrstrNewWords1[intWordNumber] := Copy(strNewCell1,1,(Pos(',',strNewCell1)-1)); Delete(strNewCell1,1,Pos(',',strNewCell1); intWordNumber := intWordNumber+1 end;
intWordNumber := 0; while not (Length(strNewCell2) = 0) do begin arrstrNewWords2[intWordNumber] := Copy(strNewCell2,1,(Pos(',',strNewCell2)-1)); Delete(strNewCell2,1,Pos(',',strNewCell2); intWordNumber := intWordNumber+1 end;
NewCell1 := ''; intCounter1 := 0; intCounter2 := 0; for intCounter1 to (Length(arrstrNewWords1)-1) do begin if arrstrNewWords1[intCounter1] = arrstrExistingWords1[intCounter2] then begin intCounter1 := intCounter1+1; intCounter2 := 0; end else begin if intCounter2 = (Length(arrstrExistingWords1)-1) then NewCell1 := NewCell1+','+arrstrNewWords1[intCounter1] else intCounter2 := intCounter2+1; end; end;
NewCell2 := ''; intCounter1 := 0; intCounter2 := 0; for intCounter1 to (Length(arrstrNewWords2)-1) do begin if arrstrNewWords2[intCounter1] = arrstrExistingWords2[intCounter2] then begin intCounter1 := intCounter1+1; intCounter2 := 0; end else begin if intCounter2 = (Length(arrstrExistingWords2)-1) then NewCell2 := NewCell2+','+arrstrNewWords2[intCounter1] else intCounter2 := intCounter2+1; end; end;
ClientDataSet.Edit; ClientDataSet.FieldByName('Spalte1').AsString := ClientDataSet.FieldByName('Spalte1').AsString+strNewCell1; ClientDataSet.FieldByName('Spalte2').AsString := ClientDataSet.FieldByName('Spalte2').AsString+strNewCell2; ClientDataSet.Post;
ClientDataSet.Next; end; end; |