[REBOL] REBOL/View text list refresh from code
From: gjones05:mail:orion at: 30-Jan-2001 5:40
Hi, Geza,
I see that we are like minded individuals in more ways than one: we're
Internists who like to program, are learning REBOL, and need to solve the
mystery of the updating lists. I ran into this particular problem last
week.
...
> In a same layout I have two text lists. If someone points an item in the
first
> list I want to trigger a change of the contents of the second text list.
> Unfortunately neither the /text nor /data refinements don't work for
> dynamically setting a text list again which has already been displayed
within
> a layout.
>
> How can I change a text list after composing and initializing (+ viewing)
it in
> VID ?
...
After reading the source code on text-list and using the trial-and-error
method, the attribute path that seems to do the trick is 'lines. Here was a
little test program I used to be sure that it work:
REBOL []
;data block
data-blk: [
"cars" ["chevy" "buick"]
"trucks" ["sierra" "blazer"]
"vans" ["odyssey" "caravan"]
]
;set up data for first list
temp: copy []
while [not tail? data-blk] [
append temp first data-blk
data-blk: skip data-blk 2
]
lo1: layout [
across
tl1: text-list data temp [tl2/lines: select b value show tl2]
tl2: text-list
below
b1: button "unview" [unview/all]
]
view lo1
The pertainent information that you seek is in the "action" portion of the
first text-list:
tl1: text-list data temp [tl2/lines: select b value show tl2]
value
is returned by selecting from the first list. The algorithm finds
the nested block associated with "value", and assigns this block to the
second list's "lines" attribute.
I have since expanded the concept to include data that is up to 5 levels
deep using four linked text lists to get at the final value. There were
4382 discrete elements in the original database. I worried that the parsing
that I added in would make the system too slow. But it is surprisingly fast
and works more quickly than JavaScript in my testing.
Hope that this information answers your question.
--Scott