Hi Sabu

I think that you are making things very difficult for yourself by using 
the word Name in both the person and family objects. You probably can 
get it to work by clever use of bind ..but a much simpler approach is 
to change one of the "name"s. Your function then works:

 >> clanobj: make object! [clan: none name: "Ahem"]
 >> me: make object! [firstname: "Sabu" surname: "Francis"
[    family: make clanobj [clan: "Vadukkut"]]
 >> getValInObject me 'clan
== "Vadukkut"
 >> getValInObject me 'name
== "Ahem"
 >> getValInObject me 'firstname
== "Sabu"

Regards

Peter

On Sunday, January 28, 2007, at 02:39  am, Sabu Francis wrote:

> Hi:
> I have a tree object wherein I want to search the value of a member (or
> return none). I have got this function "getValInObject"
> but it searches shallowly. I want an option so that it can either 
> search
> shallow or deep (breadth first, or depth first) through the tree 
> structure.
> Forgive me if I am a bit lazy in working this out myself.
>
> I would be grateful if someone can point correct this. Also I would be 
> even
> more grateful if I can get a function where I can take the possible 
> value of
> a member and return the parent object where the member is nested into. 
> For
> e.g. In the example below I should have a function which will return 
> the
> object "Me" when asked to search that object where the clan is 
> "Vadukkut"
> (Something like a reverse search?)
>
> Forgive my terminologies. I am not a computer programmer in the 
> traditional
> sense.
>
> Regards
> SF
>
>
> clanobj: make object! [clan: none  Name: "Ahem"]
>
> Me: make object! [ Name: "Sabu" Surname: "Francis" Family: make 
> clanobj [
> clan: "Vadukkut"] ]
>
> ;Get a Value anywhere inside the object ... searches shallowly all 
> nested
> objects
>
> getValInObject: func [object Member /local val v][
>
>    val: get in object Member
>    either val <> none [return val]
>     [
>      foreach word next first object [
>            v: get in object word
>            if object! =  type? v [
>            return getValInObject v Member
>           ]
>      ]
>     ]
>
> ]
>
> ;this gets the right result
> print getValInObject Me 'clan
>
> ;but I want this result to come as "Ahem"
> print getValInObject Me 'Name
>
>
> -- 
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to