home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd1.bin / zkuste / delphi / kolekce / d567 / FLEXCEL.ZIP / FlexCel / TFlxPropListImp.inc < prev    next >
Encoding:
Text File  |  2002-09-26  |  2.1 KB  |  72 lines

  1. //************************************************************************************//
  2. //  File created automatically by GenerateRecords.xls                                 //
  3. //  Do not modify by hand                                                             //
  4. //************************************************************************************//
  5.  
  6. function TFlxPropList.GetItems(index: string): variant;
  7. var
  8.   idx: integer;
  9. begin
  10.   if Find(index, idx) then Result:= (inherited items[idx] as TFlxProp).Value
  11.   else Result := unassigned;
  12. end;
  13.  
  14. procedure TFlxPropList.SetItems(index: string; const Value: variant);
  15. var
  16.   idx: integer;
  17. begin
  18.   if Find(index, idx) then
  19.     if VarIsEmpty(Value) then delete(idx) else (inherited items[idx] as TFlxProp).Value:=Value
  20.   else
  21.     if not VarIsEmpty(Value) then Add(TFlxProp.Create(index, Value));
  22. end;
  23.  
  24. function TFlxPropList.Add(aRecord: TFlxProp):integer;
  25. begin
  26.   Result:=inherited Add(aRecord);
  27.   Sorted:=false;  //When we add the list gets unsorted
  28. end;
  29.  
  30. procedure TFlxPropList.Insert(Index: Integer; ARecord:TFlxProp);
  31. begin
  32.   inherited Insert(Index, ARecord);
  33.   // We assume that when we insert, we respect the order, so we dont set Sorted=true
  34. end;
  35.  
  36. function CompareFlxProps(Item1, Item2: Pointer): Integer;
  37. begin
  38.   if TFlxProp(Item1).Name < TFlxProp(Item2).Name then Result:=-1 else if TFlxProp(Item1).Name > TFlxProp(Item2).Name then Result:=1 else Result:=0;
  39. end;
  40.  
  41. procedure TFlxPropList.Sort;
  42. begin
  43.   inherited Sort(CompareFlxProps);
  44.   Sorted:=true;
  45. end;
  46.  
  47. function TFlxPropList.Find(const aItem:string ; var Index: integer): boolean;
  48. Var
  49.  L, H, I, C: Integer;
  50. begin
  51.   if not Sorted then Sort;
  52.   Result := False;
  53.   L := 0;
  54.   H := Count - 1;
  55.   while L <= H do
  56.   begin
  57.     I := (L + H) shr 1;
  58.     if UpperCase((inherited items[i] as TFlxProp).Name) < UpperCase(aItem) then C:=-1 else if UpperCase((inherited items[i] as TFlxProp).Name)>UpperCase(aItem) then C:=1 else C:=0;
  59.     if C < 0 then L := I + 1 else
  60.     begin
  61.       H := I - 1;
  62.       If C = 0 Then
  63.       begin
  64.         Result := True;
  65.         L := I;
  66.       end;
  67.     end;
  68.   end;
  69.   Index := L;
  70. end;
  71.  
  72.