[REBOL] Re: List trouble(VID style)
From: robert:lancaster:opennw at: 29-May-2001 13:03
I prefer to use LIST with SUPPLY. As it seems to update automatically when
things are added to the list beign displayed. (providing you call show once
its updated...
Run the following in a file and click on "Add DOS" or "Add Serial". To see
things being added...
REBOL [
]
print "Starting"
default_dos: make object! [
type: 'Dos
name: copy "Blank Dos"
dos_command: copy ""
output: copy ""
run: does [
catch [
try [ call/output dos_command output ]
]
]
edit: does [
inform layout [
h2 "Dos Command"
across
text black "Name " field name [
name: copy face/text
]
text black "Command" field dos_command [
dos_command: copy face/text
]
return
output_field: field 200x200 output [ ]
return
button "Execute" [
run
output_field/text: copy output
show output_field
]
]
]
]
default_serial: make object! [
type: 'Rebol
name: copy "Blank Rebol"
command: copy " ; Comment "
output: copy ""
run: does [
catch [
try [
output: to-string do command
if equal? output none [
output: "No Output"
]
]
]
]
edit: does [
inform layout [
across
h2 "Rebol Command"
return
text black "Name " field name [
name: copy face/text
]
return
text black "Command"
field command [
command: copy face/text
]
return
output_field: field 200x200 [ ]
return
button "Execute" [
run
output_field/text: copy output
show output_field
]
]
]
]
command_list: copy []
command_offset: 0
master: layout [
below
l: list 200x100 [
across
b: text 100x20 [
face/data/run
if not equal? output none [
; Don't update the output field if nothing exists in
the
; field if the object
output/text: copy face/data/output
]
show output
][
face/data/edit
show master
]
t: text 100x20
]
supply [
temp-offset: add command_offset count
if temp-offset > length? command_list [
b/show?: false
t/show?: false
break
]
b/text: reduce [ to-string command_list/:temp-offset/name ]
b/data: command_list/:temp-offset
b/show?: true
either equal? none in command_list/:temp-offset 'type [
;If "type" does not exist in the object
t/show?: false
][
;If there exists a type value in the object display it
t/text: copy to-string command_list/:temp-offset/type
t/show?: true
]
]
return
list_slide: slider 20x100 [
command_offset: to-integer multiply face/data length?
command_list
if greater? add command_offset length? command_list add length?
command_list 5 [
command_offset: subtract length? command_list 5
]
show l
]
return
button "Shrink" [
either equal? face/data TRUE [
face/data: FALSE
output/size: 50x50
][
face/data: TRUE
output/size: 400x400
]
output_slider_y/size: make pair! reduce [ 20 pick output/size 1 ]
show output_slider_y
show master
]
add_dos: button "Add Dos" [
temp: make default_dos []
insert command_list temp
show master
]
add_serial: button "Add Serial" [
insert command_list make default_serial []
show master
]
return
button "Save List" [
save %save_list.r command_list
show master
]
button "Load List" [
command_list: reduce load %save_list.r
print command_list
show master
]
below return
across
output: field 400x400
output_slider_y: slider [ make pair! reduce [ pick output/size 2 400 ] ]
[
output/para/scroll: make pair! reduce [ 0
to-integer multiply
face/data
subtract
pick output/size 2
pick size-text output 2
]
show output
]
return
output_slider_x: slider does [ make pair! reduce [ pick output/size 1 20
] ] [
output/para/scroll: make pair! reduce [
to-integer multiply
face/data
subtract
pick output/size 1
pick size-text output 1
0
]
output_slider_x/size: make pair! reduce [ pick output/size 1 20 ]
show output
]
]
view master