Hi Sascha,

instead of:

probe first b/name

, which tries to find the first element of the B/name path (incorrect) you
could do:

1)

c: first b
probe c/name

2)

probe do-path [first b /name]

, where Do-path is as follows:

do-path: function [
    {
        A referentially transparent way
        to invoke a path.
        Usage:
            do-path [something /r1 /r2 ... /end-path a1 a2 ...]
        /end-path can be omitted, if no args are supplied.
        Values between Something and /end-path are ignored,
        if they don't evaluate to refinements or integers.
    }
    [throw]
    blk [block!]
] [something path ref] [
    set/any [something blk] do/next blk
    path: make path! reduce [
        either word? get/any 'something [something] ['something]
    ]
    until [
        any [
            empty? blk
            (
                set/any [ref blk] do/next blk
                if any [
                    refinement? get/any 'ref
                    integer? get/any 'ref
                ] [
                    not if /end-path <> ref [
                        insert tail :path either refinement? ref [
                            to word! ref
                        ] [
                            ref
                        ]
                    ]
                ]
            )
        ]
    ]
    do head insert/only copy blk :path
]

Ladislav

> Hi,
> now, what is going on here
>  >> foreach obj b [
> [    probe obj
> [    ]
>
> make object! [
>    name: "mascha"
> ]
>
> make object! [
>    name: "mascha"
> ]
>  >> probe b/1/name
> "mascha"
> == "mascha"
>  >>probe first b
>
> make object! [
>    name: "mascha"
> ]
>  >> probe first b/name
> ** Script Error: Invalid path value: name.
> ** Where: probe first b/name
>  >>
> and now:
>  >> type? [acc_1 acc_2]
> == block!
>  >> type? b
> == block!
>  >> length? [acc_1 acc_2]
> == 2
>  >> length? b
> == 2
>  >>
> but:
>  >> foreach obj [acc_1 acc_2] [
> [    probe obj/name
> [    ]
> ** Script Error: Cannot use path on word! value.
> ** Where: probe obj/name
> but (the same!)
>  >> foreach obj b[
> [    probe obj/name
> [    ]
> "mascha"
> "mascha"
> == "mascha"
>  >>?
> thanks
> Alex
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>
>
>

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

Reply via email to