Jump to content

Rebol Programming/request-dir

From Wikibooks, open books for an open world

USAGE:

[edit | edit source]
REQUEST-DIR /title title-line /dir where /keep /offset xy 

DESCRIPTION:

[edit | edit source]

Requests a directory using a popup list.

REQUEST-DIR is a function value.

REFINEMENTS

[edit | edit source]
  • /title -- Change heading on request.
    • title-line -- (Type: any)
  • /dir -- Set starting directory
    • where -- (Type: file)
  • /keep -- Keep previous directory path
  • /offset
    • xy -- (Type: any)

SOURCE CODE

[edit | edit source]
request-dir: func [
    "Requests a directory using a popup list." 
    /title "Change heading on request." title-line 
    /dir "Set starting directory" where [file!] 
    /keep "Keep previous directory path" 
    /offset xy
][
    if block? dirout [
        dirout: layout dirout 
        max-dirs: to-integer f-list/size/y - 4 / f-txt/size/y 
        center-face dirout
    ] 
    set-face f-title any [title-line "Select a directory:"] 
    if not all [keep path] [
        path: copy either where [clean-path where] [what-dir]
    ] 
    if all [not empty? path slash = last path] [remove back tail path] 
    last-path: path 
    result: none 
    show-dir 
    either offset [inform/offset dirout xy] [inform dirout] 
    result
]