[REBOL] Re: Updating a text-list
From: peoyli:algonet:se at: 20-Apr-2001 11:19
Hi,
If you only update the remote-dir word when reading a new list of files from
another site, the text-list won't know about it.. You have to update the
text-list's data block:
remote/lines: read to-url rejoin ["ftp://" ftp_user ":" ftp_passwd "@" hosts/picked]
remote/data: copy remote/lines
I really don't know why I had to update both 'data' and 'lines', but the
text-list seemed to be confused if I only updated one of these.
You will also need to call the fix-slider function (see /View FAQ) to make
the text-list's slider knob match the amount of files.
The whole (a bit modified code, to suite my local net) follows:
[
REBOL []
ftp_user: "user"
ftp_passwd: "passwd"
ftp_hosts: ["172.16.0.1" "172.16.0.5"]
;ftp_hosts: ["Annapurna" "Enigma" "Etna" "Everest" "K2"]
ftp_host: first ftp_hosts
remote-dir: read to-url rejoin ["ftp://" ftp_user ":" ftp_passwd "@" ftp_host]
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
either 0 = length? list/data [
list/sld/redrag 1
][
list/sld/redrag list/lc / length? list/data
]
]
]
ui: [
vh1 "FTP Client"
box brick 250x1
across label "Hosts:" tab hosts: text-list 100x100 data ftp_hosts
tab remote: text-list 150x100 data remote-dir
below
box brick 250x1
across button 60 "Connect" [
remote/lines: read to-url rejoin ["ftp://" ftp_user ":" ftp_passwd "@" hosts/picked]
remote/data: copy remote/lines
show remote
fix-slider remote
]
across button 60 "Cancel" []
across button 60 "Help" []
across button 60 "Options" []
]
view layout ui
]
/PeO