[REBOL] problems creating a path
From: antonr:iinet:au at: 2-Jun-2003 0:20
I am trying to call a function with certain
refinements present or not present, depending on
user switches.
This is one example that gives me what I want:
files?: true
join 'my-func/test either files? ['files][[]]
;== my-func/test/files
files?: false
join 'my-func/test either files? ['files][[]]
;== my-func/test
That joins onto the lit-path! 'my-func/test successfully or
leaves it alone.
But this example is difficult to make work, because all the
refinements of the path are optional, so the path starts as
only a single word!:
files?: true
folders?: false
to-path reduce ['my-func either files? ['files][[]] either folders?
['folders][[]]]
;== my-func/files/[]
How to get rid of the brackets?
I tried also:
to-path reduce [to-lit-path 'my-func either files? ['files][[]] either
folders? ['folders][[]]]
;** Script Error: Invalid argument: 'my-func
;** Where: to-path
;** Near: to path! :value
join to-lit-path 'my-func [either files? ['files][[]] either folders?
['folders][[]]]
;== my-func/files/[]
So using a block for the second argument is not going to work.
(Anybody know a way?)
Finally I went back to how it was working to start with:
join join to-path 'my-func either files? ['files][[]] either folders?
['folders][[]]
;== my-func/files
It seems less nice, but it works.
Anton Dale Rolls.