[REBOL] layout within an object
From: mgh520:yaho:o at: 30-Jul-2001 21:52
I got this tip from the REBOL/View developer's guide. It suggest defining a layout inside
of an object to
keep variables local and avoid confusion. I like this approach as it seems clean.
However, in the script at the end of this email, an instance variable (name) gets set
after the object is
created, and if you "print myview/name" you get the value you'd expect, i.e., Nelson
But once the view is displayed, if you click the Print button, it will print the original
value of the variable,
Edna Crabapple. It seems like the block for the Print button action is being evaluated
when it's created
and then not evaluated again when it's actually clicked.
I figured out that if I wrap the layout definition inside of a block [layout [size 640x480
....] then I can use
view do [myview/page-layout]
and get the correct results, which I believe further supports my theory that
the action is being evaluated once at the start. According to the developer's guide,
you can wrap things in
a layout with a do [...] to cause them to be evaluated once at creation time. But this
really seems to be the
Can anyone explain this behavior or should I just use the block techinque? What I haven't
show yet, is
what the value of name is once the view is closed. But I didn't know how to do that--I'm
still new at this.
Thanks in advance for any help. I hope to learn enough soon to be able to answer other's
everyone has been so helpful on this list. Thanks.
MyObject: make object! [
name: "Edna Crabapple"
page-layout: layout [
button "Print Value" [print ["name in button action:" name]]
myview: make MyObject 
myview/name: "Nelson Muntz"