comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: Searching for an object
Date: 2000/08/21
Date: 2000-08-21T00:00:00+00:00	[thread overview]
Message-ID: <8nrvc6$3r7$1@nnrp1.deja.com> (raw)
In-Reply-To: 87g0nyy1kk.fsf@moon.mteege.de

In article <87g0nyy1kk.fsf@moon.mteege.de>,
  Matthias Teege <matthias@mteege.de> wrote:
> Ted Dennison <dennison@telepath.com> writes:
> > like you are familiar with "object" notation in some other "OO"
> > languages, and are looking for the same notation in Ada. Eg: you
> > want to call Object.Find (...) rather than Find(Object, ...) Is that
> > your question?
>
> Yes, I want to call Object.Find(in_field, for_this_string)

If that's the case, then you should know that Ada does not use the
"distinguished object" notation. You will need to pass the object in
question in as a parameter. This is a FAQ, so consulting the entry at
http://www.adapower.com/lab/adafaq/16.html may help.

> but the only way to implement this I see is:
>
>         if in_field = "field1" and for_this_string = "foo"
>         then
>            result = "found";
>         if in_field = "field2" and for_this_string = "foo"
>         then
>            result = "found";
>
> and so on. The problem isn't the "object notation" but the
> record notation. I can access an record field with

Now this is beginning to look like a different question. (Again, the
above will never work, because "foo" is not 25 characters long, but
we'll ignore that issue for now). If you want the user to select which
key to use, you have several options:

   o  Make multiple "Find" routines, one for each key the user might
want to search on.

   o  Put the keys for each entry in an array in that entry, and have
the user pass in the index of the key they want to search on. You can
make this look nicer by indexing the array by an enumerated type rather
than by an integer.

   o  Change the interface to have the user pass in the value of the
key, rather than the entire object. This wouldn't work on a real linked
data structure, since each entry has its own keys. But it would suffice
for the toy example you gave above.

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-08-21  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-18  0:00 Searching for an object Matthias Teege
2000-08-21  0:00 ` Ted Dennison
2000-08-21  0:00   ` Matthias Teege
2000-08-21  0:00     ` Ted Dennison [this message]
2000-08-21  0:00     ` tmoran
2000-08-22  0:00       ` Matthias Teege
2000-08-22  0:00         ` tmoran
2000-08-21  0:00 ` Gerald Kasner
2000-08-21  0:00   ` Matthias Teege
2000-08-31 21:55 ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox