Text-List oddity?
[1/4] from: jvargas::whywire::net at: 14-Jun-2003 16:43
Hello all. I don't remember if I introduce myself before, but I had
done some postings here and there. I am newbie/intermediate
programmer try to get a good understating of Rebol. Which BTW,
I like everyday more and more.
However sometimes I find things that just don't make any sense.
Can any one explain why the keys-tl face doesn't get refresh in
the following script?
db: [ key1 "value1" key2 "value2"]
lay: layout [
keys-tl: text-list
with [
texts: copy []
]
load-btn: btn "Show keys"
[
keys-tl/texts: copy extract db 2
probe keys-tl/texts
show keys-tl
]
]
view lay
Thanks, Jaime
-- The best way to predict the future is to invent it -- Steve Jobs
[2/4] from: carl::cybercraft::co::nz at: 24-Dec-2003 22:20
On 15-Jun-03, Jaime Vargas wrote:
> Hello all. I don't remember if I introduce myself before, but I had
> done some postings here and there. I am newbie/intermediate
<<quoted lines omitted: 17>>
> ]
> view lay
Hi Jaime,
I'm not sure if there's a way to get your method to work, but I
normally place text-list values in its data block by inserting them
into it. ie, something like this...
db: [ key1 "value1" key2 "value2"]
lay: layout [
keys-tl: text-list data []
load-btn: button "Show keys"
[
insert clear keys-tl/data copy extract db 2
probe keys-tl/data
show keys-tl
]
]
view lay
Hope that helps.
--
Carl Read
[3/4] from: brett:codeconscious at: 15-Jun-2003 10:51
Hi Jamie,
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
this:
db: [key1 "value1" key2 "value2"]
lay: layout [
keys-tl: text-list
with [
texts: copy []
]
load-btn: btn "Show keys"
[
keys-tl/lines: copy extract db 2
keys-tl/update ; If using View 1.2.8+
probe keys-tl/texts
show keys-tl
]
]
view lay
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
styles).
Regards,
Brett.
[4/4] from: jvargas:whywire at: 15-Jun-2003 19:01
Thanks Carl and Brett. This is now clear. It just takes sometime to
get accustomed to VID. And it is easy to forget that is just an
specification
dialect and not the real implementation. -- Jaime
On Saturday, June 14, 2003, at 08:51 PM, Brett Handley wrote:
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted