Rebol 编程/request-file
外观
< Rebol 编程
REQUEST-FILE /title title-line button-text /file name /filter filt /keep /only /path /save
使用文件和目录的弹出列表请求文件。
REQUEST-FILE 是一个函数值。
- /title -- 更改请求标题。
- title-line -- 请求标题行(类型:任何)
- button-text -- 选择按钮文本(类型:任何)
- /file
- name -- 默认文件名或文件名块(类型:任何)
- /filter
- filt -- 过滤器或过滤器块(类型:任何)
- /keep -- 保留之前的设置和结果
- /only -- 只返回单个文件,而不是块。
- /path -- 返回绝对路径,后面跟着相对文件。
- /save -- 请求保存文件,否则加载。
request-file: func [
{Requests a file using a popup list of files and directories.}
/title "Change heading on request."
title-line "Title line of request"
button-text "Button text for selection"
/file name "Default file name or block of file names"
/filter filt "Filter or block of filters"
/keep "Keep previous settings and results"
/only "Return only a single file, not a block."
/path "Return absolute path followed by relative files."
/save "Request file for saving, otherwise loading."
/local where data filt-names filt-values
][
if none? out start-out
either file [
either block? name [picked: copy name] [picked: reduce [to-file name]]
] [
if not keep [picked: copy []]
]
if none? picked [picked: copy []]
if file: picked/1 [where: first split-path file]
while [not tail? picked] [
set [name file] split-path first picked
either name <> where [remove picked] [
change picked file
picked: next picked
]
]
picked: head picked
if any [not where not exists? where] [where: clean-path %.]
if not keep [
fp/data: head fp/data
so/data: head so/data
si: 1
]
either filter [
filters: either block? filt [filt] [reduce [filt]]
] [if any [not keep not block? filters] [pick-filter]]
ff/text: form filters
tt/text: either title [copy title-line] ["Select a File:"]
ob/text: either title [copy button-text] ["Select"]
if all [
error? done: try [
filt-names: copy head fp/data
filt-values: copy filter-list
either filter [
insert head filt-names "Custom"
insert/only filt-values filters
] [
filt-names: at filt-names index? fp/data
]
done: local-request-file data: reduce
[tt/text ob/text clean-path where picked filt-names filt-values found? any [only] found? any [save]]
if done [
dir-path: data/3
picked: data/4
if not filter [fp/data: at head fp/data index? data/5]
]
done
]
(get in disarm done 'code) = 328
] [
done: false
read-dir/full either where [where] [dir-path]
show-pick
inform out
unfocus
]
if error? done [done]
if all [done picked any [path not empty? picked]] [
either path [
done: insert copy picked copy dir-path
either only [done/1] [head done]
] [
foreach file picked [insert file dir-path]
either only [picked/1] [picked]
]
]
]