Hi Kai,

A deeper understanding of CONTEXT is required.
CONTEXT just MAKEs an object!
When MAKEing an object, the spec block is first scanned
for set-words, but only in the top level.
Those set-words that were found in the scan are added
to the new object. eg:

        probe context [a: none do [b: none]]

Only A is added to the new object because B: is in a sub-block.

In your example, when building CTX, only CHANGE-TEXT: and 
FORM2: were found in the top level, which you can verify:

        probe first ctx

If you want a word added to a context which is only
set in a sub-block, then set it to none in the top-level first.
eg:

        context [
                f2text: none
                change-text: ...
                ...
        ]

And that explains why F2TEXT was available to SHOW-FORM2;
F2TEXT was not bound to CTX, so when you set it, it was
set global.

Anton.

> Why does Rebol not complain about
> 'f2text not having a value in 'show-form2????
> 
> It forces me to use the context to talk to the
> layout and the 'change-text function which makes
> good sense to me.
> 
> How come it "sees" the "sub-part" 'f2text when
> it cannot "see" its parent?
> 
> Would one of the gurus please shed some light
> on this for me?
> 
> As always, thanks a lot!
> Kai
> 
> 
> 
> rebol[]
> 
> ;-------------------------------------------
> show-form2: does [
>    unview  
>    view/new ctx/form2 ; makes good sense
>    ctx/change-text    ; makes good sense
>    set-face f2text "GREEN"  ; ??????
> ]
> 
> ;-------------------------------------------
> form1:  center-face layout [
>   btn "Show form 2" [ show-form2 ]
> ]
> 
> ;-------------------------------------------
> ctx: context [
>    change-text: does [ set-face f2text "BLUE" ]
>    ;    
>    form2: center-face layout [
>       f2text: text "RED"
>    ]
> ]
> 
> ;-------------------------------------------
> view form1

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

Reply via email to