tags:

views:

67

answers:

1

I have a block on which I want to iterate recursively

folders: [
    Chrome [
        content [
            preferences
            prefpages
        ]
    ]
    icons [
        default
    ]
    locale [
        en-EN [
            csbar
        ]
    ]
    skin
]

with this function:

iterate-folder: func [folders [block!]][
    foreach folder folders [
        either not block? folder [
            probe folder
            temp: folder
            input
        ] [
            print "folder"
            probe folder
            print "folders"
            probe folders
            probe select folders folder
            type-folder: type? select folders folder
            probe type-folder
            input
            iterate-folder select folders folder
        ]
    ]
]

but for stupid reason I can't see, probe folder returns none above so it doesn't work.

+3  A: 

It's that select folders folder that is messsing it up, I think.....folder is already the data structure you want.

Try this (note also the ask rather than input just to add a debugging string at that point):

iterate-folder: func [folders [block!]][
    foreach folder folders [
        either not block? folder [
            probe folder
            temp: folder
            ask "continue/not block"
    ] [
            print "folder"
            probe folder
            print "folders"
            probe folders
            probe select folders folder
            type-folder: folder
            probe type-folder
            ask "continue/block"
            iterate-folder folder 
        ]
    ]
]
Sunanda
Thank you seems to work :)
Rebol Tutorial