[REBOL] Re: Text-List oddity?
From: brett:codeconscious at: 15-Jun-2003 10:51
Carl's response shows what is probably the best way to do what you want.
The reason for your problem can only be understood with reference to the
internals of text-list. When a text-list is created some initialisation
takes place that puts the data in a specific variable. For text-list this is
the Lines variable. Lines refers to a block of lines to display and this
is what Text-List uses.
During initialisation if the Data variable is none, the Texts variable is
used to set it. Then the Lines variable is set with the Data variable.
Because of the way references to blocks work, if you manipulate the block
referenced by Data, you are in fact manipulating the Lines block.
So you could just change your code to set the Lines variable only. Like
db: [key1 "value1" key2 "value2"]
lay: layout [
texts: copy 
load-btn: btn "Show keys"
keys-tl/lines: copy extract db 2
keys-tl/update ; If using View 1.2.8+
But then if you forget, or use some other code that assumes Data has a valid
reference, you'll get a problem. So you would need to set Texts, Data and
Lines all to the same new block. But that is not ideal either, because if
VID changes (quite possible) your code could break. So it is much better to
do as Carl recommends, and that is to clear the existing block and insert
the new contents.
One thing to remember about VID, is that specification you give Layout is
used during the construction of View faces and is not used once the face has
been created. Also, many of the VID styles carry out important work during
their construction *only*. Once the face is created, its behaviour and look
is determined by its internal variables and functions - not by the original
specification block. Perhaps for these styles, an assumption was made by
the designer that a relatively fixed style is all that would normally be
required (this doesn't preclude someone from developing more complex dynamic