comp.lang.ada
 help / color / mirror / Atom feed
From: Matthias Teege <matthias@mteege.de>
Subject: Re: Searching for an object
Date: 2000/08/22
Date: 2000-08-22T00:00:00+00:00	[thread overview]
Message-ID: <87vgwte9yo.fsf@moon.mteege.de> (raw)
In-Reply-To: Euio5.122343$i5.1793130@news1.frmt1.sfba.home.com

tmoran@bix.com writes:

> >        if in_field = "field1" and for_this_string = "foo"
> >        then
> >           result = "found";
> >        if in_field = "field2" and for_this_string = "foo"
> >        then
> >           result = "found";
> >
> >I'm looking for a short notation like
> >"record.$fieldname". I hope I can make you understand. :-)
>   I'm confused.  The example pseudo-code indicates there are
> two fields, "in_field" and "for_this_string", while
> record.$fieldname suggests, to me, that you want multiple
> different field names in your record.

No, the pseudo code deceive. I have an record type with
for instance two fields and "in_field" stands for the
fieldname and "for_this_string" stands for the value.

type Customer is 
   record 
        lastname  : String ( 1..10 );
        firstname : String ( 1..10 );
   end record

Cust : Customer;

Cust.lastname  = "Teege     ";
Cust.firstname = "Matthias  ";

Now I build an container with a lot of customers and wan't
to find one of them. For this case I look for an procedure
which I can pass two arguments. Not only the searchstring
(Teege) but also the fieldname (lastname).

A appropriate call looks like this: 

Find("lastname", "Matthias  "); -- not found
Find("lastname", "Teege     "); -- found

>   If you don't like the successive "if"s, how about

Yes, that is the problem, too many "if's". :-)

>    if for_this_string = "foo"
>    and then ada.strings.fixed.index("field1 field2", in_field) /= 0 then
>      result := "found";
> (assuming, of course, that all strings are the indicated length).
>   If I understand correctly what you mean by record.$fieldname, why
> not just have the record contain an array of the fields?

You, TED and the others gave a lot of input and I will try
to recycle some of them. ;-)

Many thanks
Matthias

-- 
Matthias Teege -- matthias@mteege.de -- http://emugs.de
make world not war
PGP-Key auf Anfrage




  reply	other threads:[~2000-08-22  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 ` Gerald Kasner
2000-08-21  0:00   ` Matthias Teege
2000-08-21  0:00 ` Ted Dennison
2000-08-21  0:00   ` Matthias Teege
2000-08-21  0:00     ` Ted Dennison
2000-08-21  0:00     ` tmoran
2000-08-22  0:00       ` Matthias Teege [this message]
2000-08-22  0:00         ` tmoran
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