[REBOL] Re: problems creating a path
From: brett:codeconscious at: 4-Jun-2003 16:31
Well my only suggestion was along the lines of treating your refinements as
data and introducing a loop and then I got carried away...
; --- 8< ---------------------------------------
;
; Our list of refinements.
; Might be good to add labels :)
;
refinements: [
show-folders show-files show-images absolute-paths details
]
;
; Our simulated function.
;
funcspec: copy refinements
forall funcspec [change funcspec to refinement! funcspec/1]
traverse: func head funcspec compose/deep [
reduce [(:refinements)]
]
;
; A generated layout of checkboxes.
; Each with a special refinement facet.
;
layout-spec: copy [
style rcheck check [redisplay]
across
label "path: " txtPath: text 400 return
label "result: " txtResult: text 400 return
]
foreach refinement refinements [
append layout-spec compose/deep [
label 100 (join to-string refinement ":")
rcheck with [
refinement: (to lit-word! :refinement)
]
return
]
]
;
; Computes the path based on the checkboxes found in pane.
; I suggest that this bit is fairly compact while retaining
; the flexibility of adding refinements later. And it does not
; add any new words except the facet refinement which
; I would say is data storage :)
function-path?: func [
pane [block!] /local p fld
] [
p: to path! 'traverse
foreach face pane [
if all [
in face 'refinement
face/data
] [append p face/refinement]
]
:p
]
;
; A function to update the display.
; Assuming our layout is the first in the pane.
;
redisplay: has [path] [
path: function-path? layout-face/pane
txtPath/text: mold path
txtResult/text: mold do reduce [function-path? layout-face/pane]
show layout-face
]
;
; View the layout.
;
view layout-face: layout layout-spec
; ---8<---------------------------------------
Regards,
Brett.