Einzelnen Beitrag anzeigen

Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.343 Beiträge
 
Delphi 11 Alexandria
 
#29

AW: Objectlist sortieren

  Alt 11. Aug 2016, 16:40
Delphi-Quellcode:
  
// --------------------------------------->
function CompareItem(Item1, Item2: Pointer): Integer;
var
   ArtValues1: TArtValues;
   ArtValues2: TArtValues;
begin
   ArtValues1 := TArtValues(Item1);
   ArtValues2 := TArtValues(Item2);

   if ArtValues1.ArtNr<ArtValues2.ArtNr then
   begin
     Result := -1;
     Exit;
   end;
   if ArtValues1.ArtNr>ArtValues2.ArtNr then
   begin
     Result := 1;
     Exit;
   end;

   Result := 0;
end;
// <---------------------------------------

   procedure ReadGlobalInformations;
   Var
     j,z,k : Integer;
   Begin
     iCNT1 := 1;
     iPos1 := iGeneralPos[0];
     for k := 0 to sWriteDataSet.count -1 do
     Begin
       if k > 0 then
       Begin
         sGValueList.Clear;
         sGValueList.DelimitedText := StringReplace(sWriteDataSet[iCNT1],' ','_',[rfReplaceAll]);
         if sGValueList[iPosArt] <> 'then
         Begin
           for z := 1 to iPos1 - 1 do
           Begin
             if sGValueList[z] <> 'then
             Begin
               oArtValues := TArtValues.Create;
               oArtValues.iArtNr := StrToInt(sGValueList[iPosArt]);
               oArtValues.sArt := 'G';
               oArtValues.sDescription := ArtPropertyName[z];
               oArtValues.iColNr := z+1;


               sTemp0 := sGValueList[z];
               Delete(sTemp0,pos('\PIM_Webbilder\',sTemp0),Length('\PIM_Webbilder\'));
               oArtValues.sVal := StringReplace(sTemp0,'_',' ',[rfReplaceAll]);
               oArtValues.sVal255 := StringReplace(sTemp0,'_',' ',[rfReplaceAll]);
               FVArtValues.Add(oArtValues);
             end;
           end;
             INC(iCNT1);
         end
         else
           INC(iCNT1);
       end;
     end;
   end;

// General Informations
   procedure ReadGeneralInformations;
   Var
     z,k : Integer;
   Begin
     iCNT1 := 1;
     iPos1 := iGeneralPos[0];
     iPos2 := iGeneralPos[1];
     iPos3 := iGeneralPos[2];
     for k := 0 to sWriteDataSet.count -1 do
     Begin
       if k > 0 then
       Begin
         sGValueList.Clear;
         sGValueList.DelimitedText := StringReplace(sWriteDataSet[iCNT1],' ','_',[rfReplaceAll]);
         if sGValueList[iPosArt] <> 'then
         Begin
           for z := iPos1 to iPos2 - 1 do
           Begin
             if (sGValueList[iPos1] <> '') and (sGValueList[iPos2] <> '')then
             Begin
               oArtValues := TArtValues.Create;
               oArtValues.iArtNr := StrToInt(sGValueList[iPosArt]);
               oArtValues.sArt := 'A';
               oArtValues.sDescription := ArtPropertyName[iPos1];
               oArtValues.iColNr := iPos1+1;
               oArtValues.sVal := StringReplace(sGValueList[iPos1],'_',' ',[rfReplaceAll]);;
               oArtValues.sVal255 := sGValueList[iPos2];
               oArtValues._Unit := sGValueList[iPos3];
               FVArtValues.Add(oArtValues);
               INC(iPos1);
               INC(iPos2);
               INC(iPos3);
             end
             else
               Break;
           end;
           Begin
             INC(iCNT1);
          end;
         end
         else
           INC(iCNT1);
       end;
     end;
   end;

// Individually Informations
   procedure ReadIndividuallyInformations;
   Var
     z,k : Integer;
   Begin
     iCNT1 := 1;
     iPos4 := iIndividuallyPos[0];
     iPos5 := iIndividuallyPos[1];
     iPos6 := iIndividuallyPos[2];
     for k := 0 to sWriteDataSet.count -1 do
     Begin
       if k > 0 then
       Begin
         sGValueList.Clear;
         sGValueList.DelimitedText := StringReplace(sWriteDataSet[iCNT1],' ','_',[rfReplaceAll]);
         if sGValueList[iPosArt] <> 'then
         Begin
           for z := iPos4 to sGValueList.count{iPos5}- 1 do
           Begin
             sTemp0 :=sGValueList[iPos4];
             sTemp1 :=sGValueList[iPos5];
             sTEmp2 := IntToStr(z);
             if iPos6 < sGValueList.count - 1 then
             Begin
               if (sTemp0 <> '') and (sTemp1 <> '')then
               Begin
                 oArtValues := TArtValues.Create;
                 oArtValues.iArtNr := StrToInt(sGValueList[iPosArt]);
                 oArtValues.sArt := 'I';
                 oArtValues.sDescription := ArtPropertyName[iPos4];
                 oArtValues.iColNr := iPos4+1;
                 oArtValues.sVal := StringReplace(sGValueList[iPos4],'_',' ',[rfReplaceAll]);;
                 oArtValues.sVal255 := sGValueList[iPos5];
                 oArtValues._Unit := sGValueList[iPos6];
                 FVArtValues.Add(oArtValues);
                 INC(iPos4);
                 INC(iPos5);
                 INC(iPos6);
               end
               else
               Begin
                 INC(iPos4);
                 INC(iPos5);
                 INC(iPos6);
               end;
             end
             else
               Break;

           end;
           Begin
             iPos4 := iIndividuallyPos[0];
             iPos5 := iIndividuallyPos[1];
             iPos6 := iIndividuallyPos[2];
             INC(iCNT1);
          end;
         end
         else
         INC(iCNT1);
       end;
     end;
   end;

// ------------------------------------------->
...
ReadGlobalInformations;
ReadGeneralInformations;
ReadIndividuallyInformations;
FVArtValues.Sort(CompareItem);
...
// <-------------------------------------------

Passt hoffentlich so.

@DeddyH
Stimmt! Gerade nachgesehen:
http://docs.embarcadero.com/products...rtCompare.html
Zitat:
>0 (positive)
Item1 is greater than Item2

0
Item1 is equal to Item2

<0 (negative)
Item1 is less than Item2
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat