newbie text-list questions
[1/3] from: kpeters:mvinc at: 10-Oct-2003 19:59
Hi list ~
How do I
- add lines to a text-list dynamically
- knowing that any windows control of this type can only hold a finite number of list
items, how do i clear a text-list say every 1,000 entries?
Thanks,
Kai
[2/3] from: carl:cybercraft at: 24-Dec-2003 22:39
On 11-Oct-03, Kai Peters wrote:
> Hi list ~
> How do I
> - add lines to a text-list dynamically
> - knowing that any windows control of this type can only hold a
> finite number of list items, how do i clear a text-list say every
> 1,000 entries?
The lines in a text-list are held in a block called data, so...
view layout [
t: text-list
button "Add Line" [
append t/data to-string random 10000
show t
]
button "Clear" [
clear t/data
show t
]
; Sort example added while I'm at it...
button "Sort" [
sort/compare t/data func [a b][(to-integer a) < to-integer b]
show t
]
]
(Note you can cut and paste that layout directly into the View Console
to test it, just in case you've not discovered this feature yet.)
use...
length? t/data
to check how many items are in the above list.
There are of course ways to update the scroll-bar, but I can't
remember the current best method, (it's been improved with the beta
versions I think), so someone else would be best to explain that.
Hope that helps.
--
Carl Read
[3/3] from: ingo::2b1::de at: 11-Oct-2003 18:51
Hi Kai,
Carl Read wrote:
> On 11-Oct-03, Kai Peters wrote:
<...>
> button "Clear" [
> clear t/data
> show t
> ]
<...>
One thing you should be aware of: you should only _change_the_series_,
e.g. if you'd use
t/data: copy [] ; ATTENTION: That's most surely not what you want
the text-list would still hold on to the original series, but you would
never be able to access it again ...
to see what I mean, just play around with this ...
view layout [
tl: text-list "1" "2" "3"
button "add" [append tl/data form now show tl]
button "Falsely clear" [tl/data: ["a" "b" "c"] show tl]
]
Kind regards,
Ingo