Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Forms with separate context

 [1/4] 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

 [2/4] from: gscottjones:mchsi at: 15-Dec-2002 16:53


From: "Davide Gessi" ...
> 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 ?
...
> But I would investigate if a better method exists. > Hope my question is clear, my english is poor :(
... full post: http://www.escribe.com/internet/rebol/m28775.html Hi, Davide, I don't know if I can provide the *best* method, but here is one that demonstrates several little tricks that may help: REBOL [] chatters: copy [] chat: make object! [ nome: copy "" frm: [ (to-set-word join 'titolo nome) h2 (join "Chatting with: " nome) area ] show: does [ view/new frm-chat: layout compose frm do [ append chatters to-word join 'titolo nome chatters: unique chatters ] ] ] 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" [ foreach chatter chatters [ print get in do chatter 'text ] ] ] Hope that helps. --Scott Jones

 [3/4] from: g:santilli:tiscalinet:it at: 16-Dec-2002 0:19


Hi Davide, You were very close. On Sunday, December 15, 2002, 6:19:45 PM, you wrote: DG> chat: make object! [ DG> nome: copy "" DG> frm: [ DG> titolo: h2 (join "Chatting with: " nome) DG> area DG> ] DG> show: does [ DG> view/new frm-chat: layout compose frm DG> ] DG> ] Try with: chat: make object! [ nome: copy "" titolo: frm-chat: none frm: [ titolo: h2 (join "Chatting with: " nome) area ] show: does [ view/new frm-chat: layout compose frm ] ] Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [4/4] from: davidegessi:tin:it at: 19-Dec-2002 2:30


Gabriele and Scott, thanks.. my messenger now supports multi chat :) Davide