[REBOL] Forms with separate context
From: davidegessi:tin:it at: 15-Dec-2002 18:19
Hi all,
giving the following code:
<code>
REBOL []
chat: make object! [
nome: copy ""
frm: [
titolo: h2 (join "Chatting with: " nome)
area
]
show: does [
view/new frm-chat: layout compose frm
]
]
chat1: make chat [
nome: "Davide"
]
chat2: make chat [
nome: "Luca"
]
view layout [
button "Show Davide" [chat1/show]
button "Show Luca" [chat2/show]
button "Print values" [
print chat1/titolo/text
print chat2/titolo/text
]
]
</code>
this raise an error when I push the "print values" button...
After this example I understood that the context of "titolo" isn't the
object chat, but it's the global context, and I have only one var "titolo".
Now my big question is: what is the best method to have a collection of
similar form, with separate context for each of them ?
I have seen that in the code of the jabber client "Maoww.r" (my rebol
bible) this is done using "do" with a string built appending the ID of the
form to every control name, like this:
do rejoin [
nome {titolo: h2 (join "Chatting with: " nome)}
]
so I could modify my code:
button "Print values" [
print Davidetitolo/text
print Lucatitolo/text
]
But I would investigate if a better method exists.
Hope my question is clear, my english is poor :(
Thanks in advance.
Ciao
Davide