Re: Filter of TObjects

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 09/22/04


Date: Wed, 22 Sep 2004 10:13:41 +0200


"Bernd Pocher" <BerndPocher@freenet.de> wrote in message
news:4150a2ad$0$32699$9b622d9e@news.freenet.de...

> I have some lists with different TObjects and I will filtering this
> with a statement e.g.
> val1 = 20 and val2 = 'hallo' or val3 = Green

TObject does not have val1, val2, or val3 properties. You need to
assume/enforce that the list contains only objects that do. The
big problem is to let the compiler know it; options are casting or
querying for interfaces.

> val1 = integer
> val2 = string
> val3 = set of or enumerates
>
> I don't have writen a filter without a database any time. So I need
> background information. Or exists anywhere a control?

This is a real programming problem. Be prepared to write actual code,
hundreds or thousands of lines.

The actual filtering code isn't hard, because it defers all the hard
work. (This is called top-down programming.)

i:=0;
while (i<list.count) do begin
  if pass_filter(list.items[i], test)
  then inc(i)
  else list.delete(i);
end;

Pass_filter() is a function that performs a test (second parameter) on
an object (first parameter). Do not underestimate the thought that
should go into the test parameter. The first candidate is perhaps a
string "(val1=20) and (val2='hallo') and (val3=green)", but that
means you have to interpret that string, fill in the variables from the
object you have, and evaluate the resulting expression. Well, you
probably have to do that anyway, but you can do a lot of preprocessing
so the "test" passed to pass_filter can be an object of your own
devising.

Groetjes,
Maarten Wiltink



Relevant Pages

  • Re: Quarantine rqc parameter details
    ... Regarding the first parameter which you pass to rqc, it is the name of the ... dial up connectoid which is created when you installed the CM profile. ... STRING to the RQS on the server side. ...
    (microsoft.public.isa.vpn)
  • Re: Quarantine rqc parameter details
    ... Regarding the first parameter which you pass to rqc, it is the name of the ... dial up connectoid which is created when you installed the CM profile. ... STRING to the RQS on the server side. ...
    (microsoft.public.isa)
  • Re: Quarantine rqc parameter details
    ... Regarding the first parameter which you pass to rqc, it is the name of the ... dial up connectoid which is created when you installed the CM profile. ... STRING to the RQS on the server side. ...
    (microsoft.public.isa)
  • Re: Quarantine rqc parameter details
    ... Regarding the first parameter which you pass to rqc, it is the name of the ... dial up connectoid which is created when you installed the CM profile. ... STRING to the RQS on the server side. ...
    (microsoft.public.win2000.ras_routing)
  • Re: Quarantine rqc parameter details
    ... Regarding the first parameter which you pass to rqc, it is the name of the ... dial up connectoid which is created when you installed the CM profile. ... STRING to the RQS on the server side. ...
    (microsoft.public.win2000.ras_routing)