You could use the /local refinement like this:

list-dirs: func [
        "returns dir tree as block"
        dir [file!] "root dir"
        /local dirtree           ; A change here
        ]
        [
        dirtree: make block! 100
        foreach name read dir [
                if dir? dir/:name [
                   append dirtree dir/:name
                   list-dirs dir/:name
                ]
        ]
        dirtree
]

Or you could the other way to define a function like this:

list-dirs: function [        ; A change here
        "returns dir tree as block"
        dir [file!] "root dir"
        ][dirtree]           ; A change here - this block specifies the
locals
        [
        dirtree: make block! 100
        foreach name read dir [
                if dir? dir/:name [
                   append dirtree dir/:name
                   list-dirs dir/:name
                ]
        ]
        dirtree
]

Brett.

Reply via email to