On 13-Dec-01, Robert M. Muench wrote:

> Hi, I have the following problem:

> I'm handling objects, with several data-fields, in a series and now
> want to find an object with a specific value in a data-field. The
> problem is that 'find doesn't browse through the values.

> Any tip how I can search for values in data-fields of objects?
> Robert

The following function might do the job for you, though I's sure there
must be a better way...

obj-find: func [series field value][
    forall series [if series/1/:field = value [return index? series]]
    none
]

s: reduce [
    make object! [a: 10 b: "a"]
    make object! [a: 20 b: "b"]
    make object! [a: 30 b: "c"]
    make object! [a: 40 b: "d"]
]

>> obj-find s 'a 20
== 2
>> obj-find s 'a 50
== none
>> obj-find s 'b "d"
== 4

-- 
Carl Read

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to