VID question: global words
[1/5] from: robert::muench::robertmuench::de at: 4-Nov-2002 11:33
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
]
What happens in this case:
layout [
box1: box
box2: box
]
And now I have code that makes:
box1/pane: layout [
f1: fld "test"
f2: inf "bla"
f3" btn
]
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? Robert
[2/5] 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?
<<quoted lines omitted: 3>>
> 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
[3/5] from: robert:muench:robertmuench at: 4-Nov-2002 17:14
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 6>>
> words linked to another context (user defined), layout will
> use that user defined context.
Hi, ok. That's what I assumed. Ok, what to do if I want to mix words
from different contexts in one layout:
A: context [a: none]
B: context [b: none]
C: none
Layout [
a/a: field "a/a"
b/b: field "b/b"
c: field "C"
]
IIRC a/a can't be used in layout.
> 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:?
Yep, still to many years C++ programming ;-)).
> 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!
Ok, but for this you have to create layout within the context of the
object as well. IMO there is no necessarly a direct relation between an
object and a layout.
> The word box2/f1 does not exists: has not been created.
Ups, sorry I used a bad syntax here. I just want to referr to the second
f1 definition not the first :-(. But now I think the global word f1 will
be set to a new value.
> First, you must create it with the 'with expression:
> ...
> Layout will create and bind the words for you.
Hell, this is quite complicated. Thansk for the answer, I have to read
it some more times and pay around with it. Robert
[4/5] from: rotenca:telvia:it at: 4-Nov-2002 19:05
Hi Robert:
> Hi, ok. That's what I assumed. Ok, what to do if I want to mix words
> from different contexts in one layout:
<<quoted lines omitted: 7>>
> ]
> IIRC a/a can't be used in layout.
Not so simple (because of the path limitation of layout).
Paths make binds for you, without path, you must bind manually:
layout compose [
(bind [a:] in a 'a) field "a/a"
(bind [b:] in b 'b) field "b/b"
]
This is another try:
layout bind bind [a: field "a/a" b: field "b/b"] in a 'a in b 'b
in the latter you must be sure that there are not the words with the same name
in contexts.
---
Ciao
Romano
[5/5] from: brett:codeconscious at: 5-Nov-2002 10:04
At some point the solution to your immediate objective may become too
expensive (time to understand, maintain, etc) when compared with your
overall goal.
So Robert, what is it you actually want to achieve in terms of variables and
faces?
Maybe an entirely diferent approach will be more suitable.
Regards,
Brett.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted