[REBOL] Re: VID question: global words
From: rotenca:telvia:it at: 4-Nov-2002 13:49
Hi, Robert
> Hi, as I understand VID the following block for layout will create
> global words for f1, f2 and f3. Is this correct?
>
> layout [
> f1: fld "test"
> f2: inf "bla"
> f3" btn
> ]
It is correct, because in this example f1 f2 f3 are set words linked to the
context system/words. If you pass to Layout words linked to another context
(user defined), layout will use that user defined context.
In Rebol it is better to think in term of contexts not of words: the question
is what is the context to which is linked the set word f1:? Layout will use
that context. Here I pass a word linked to an object context and Layout will
use that context.
o: context [f1: none layout [f1: button]]
type? o/f1;==object!
>What happens in this case:
...
>box2/pane: layout [
> f1: fld "test"
> f2: inf "bla"
> f3" btn
>]
>What will the global word f1 etc. referr to now? Only to box2/f1?
The word box2/f1 does not exists: has not been created.
First, you must create it with the 'with expression:
layout [
box1: box
box2: box with [f1: f2: f3: none]
]
in box2 'f1 ;== f1
box2/f1 ;== none
Second, you must link the word passed to Layout to the context associated to
box2:
box2/pane: layout bind [
f1: field "test"
f2: info "bla"
f3: button
] in box2 'self
type? box2/f1 ;== object!
You can do all this work with the expression:
layout [
box1: box
box2: box with [
f1: f2: f3: none
pane: layout [
f1: field "test"
f2: info "bla"
f3: button
]
]
]
Layout will create and bind the words for you.
---
Ciao
Romano