Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TSegment = class(TObject)
- private
- FId: Integer;
- FNazwa: String;
- FTyp: Integer;
- public
- constructor Create(Aid: Integer; Anazwa: String; Atyp: Integer);
- destructor Destroy;
- property id: Integer read FId write FId;
- property Nazwa: String read FNazwa write FNazwa;
- property typ: Integer read FTyp write FTyp;
- end;
- TSegmentList = class(TObjectList)
- private
- function GetItem(aindex: Integer): TSegment;
- procedure SetItem(aindex: Integer; const Value: TSegment);
- public
- constructor Create(AOwner: bool);
- destructor Destroy;
- procedure pobierzSegmenty(Query: TZQuery);
- property Items[aindex: Integer]: TSegment read GetItem
- write SetItem; default;
- function Add(ASegment: TSegment): Integer;
- function FindItem(Anazwa: String): TSegment;
- end;
- function TSegmentList.FindItem(Anazwa: String): TSegment;
- var
- tempSegment: TSegment;
- I: Integer;
- begin
- try
- tempSegment := TSegment.Create(-1,'',-1);
- result := tempSegment;
- for I := 0 to self.Count -1 do
- if self.Items[I].Nazwa = Anazwa then
- begin
- FreeAndNil(tempSegment);
- tempSegment := TSegment.Create(self.Items[I].id, self.Items[I].Nazwa,
- self.Items[I].typ);
- //tempSegment := self.Items[i] as TSegment;
- Result := tempSegment;
- break;
- end;
- except
- on e:exception do fmMain.ObsluzBlad(e,'TSegmentList.FindItem','');
- end;
- end;
- {dodano 08/09/2011}
- function TSegmentList.Add(ASegment: TSegment): Integer;
- begin
- Result := inherited Add(ASegment);
- end;
- destructor TSegmentList.Destroy;
- begin
- inherited Destroy();
- end;
Advertisement
Add Comment
Please, Sign In to add comment