From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,94b44ecb42c031b9 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Searching for an object Date: 2000/08/21 Message-ID: <8nrvc6$3r7$1@nnrp1.deja.com>#1/1 X-Deja-AN: 660824308 References: <87og2q9yyp.fsf@moon.mteege.de> <8nrh3t$ht9$1@nnrp1.deja.com> <87g0nyy1kk.fsf@moon.mteege.de> X-Http-Proxy: 1.0 x70.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Aug 21 19:19:56 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) Date: 2000-08-21T00:00:00+00:00 List-Id: In article <87g0nyy1kk.fsf@moon.mteege.de>, Matthias Teege wrote: > Ted Dennison 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.