[REBOL] Re: building a dynamic path to elements in block
From: ingo:2b1 at: 1-Nov-2000 0:42
Hi Gary,
a version that works would be:
for count 2 ( div-count + 1 ) 1 [
temp-path: to-path compose [ structure-block 1 (count)]
print temp-path
]
*** output ***
book=O
poem=1
*** /output ***
or
for count 2 ( div-count + 1 ) 1 [
print reduce [to-path compose [ structure-block 1 (count)]]
]
However, why don't you just use 'pick ?
for count 2 ( div-count + 1 ) 1 [
print pick structure-block/1 count
]
This seems the most elegant solution to me ...
regards,
Ingo
Once upon a time Gary Gallagher spoketh thus:
<...>
> for example
> [ [ 1999.01.0161 book=O poem=1 line=1 Greek] [ 1999.01.0162 book=O poem=1
> line=1 English ] ]
>
> the number of div-titles varies from document to document, but I want to
> dynamically grab them when rebuilding the xml.doc. Here's a stripped down bit
> of test code:
>
> ******code starts here*******
> div-count: ( length? structure-block/1 ) - 3
>
> for count 2 ( div-count + 1 ) 1 [
> temp-path: join 'structure-block/1["/"count]
> to-path temp-path
> print temp-path
> ]
> ******code ends here**********
>
> It gives me something like this
>
> *****example output******
> 1999.01.0161 book=O poem=1 line=1 Greek / 2
> 1999.01.0161 book=O poem=1 line=1 Greek / 3
> *****example output ends here******
>
> whereas I was expecting something like
>
> *****example output******
> book=O
> poem=1
> *****example output ends here******
<...>
--
do http://www.2b1.de/
_ . _
ingo@)|_ /| _| _ <We ARE all ONE www._|_o _ _ ._ _
www./_|_) |o(_|(/_ We ARE all FREE> ingo@| |(_|o(_)| (_|
._| ._|