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

[REBOL] Re: Viewing two or more copies of the same layout

From: brett:codeconscious at: 10-Feb-2004 20:45

At present you are making two objects (via context) which both share the same layout face (a face is an object too) - sub-objects are not cloned during Make - they are referenced/shared. A source of much debate :-)
>> a: context [o: context [name: "brett"]] >> b: make a [] >> b/o/name
== "brett"
>> append b/o/name " handley"
== "brett handley"
>> a/o/name
== "brett handley" So when your code: view/new p/lyt executes it is actually trying to put the exact same face (the one created by layout) into two difference windows - which is not allowed, hence the error message. You can achieve what you want by using your context specification twice to produce two different contexts without shared internal values. Because the whole context specification is evaluated separately you end up with two different contexts each having its own sub-object. ---snip--- patient-record: [ id: none f1: none lyt: layout [ across text "Name" f1: field return btn-enter "Save" [ ; save record to database for this id print ["Saving" f1/text] ] ] populate: func [i [integer!]] [ ; set f1/text = to name from database where id = i insert clear f1/text now ] ] p1: context patient-record p1/populate 1 view/new p1/lyt p2: context patient-record p2/populate 2 view/new p2/lyt do-events ---snip--- Cheers, Brett.