[REBOL] request-file/save/file in 1.2.47
From: charles::mougel::spinodo::com at: 3-Sep-2005 16:07
Hi,
I have a problem with request-file/save/file
There is a bug in old versions, and we can't save in a file by default :
In View 1.2.47 this script doesn't work properly :
request-file/save/file %/C/test.txt
the filename field is void when the requester appears.
I found that this bug is resolved in the 1.3 !
I make a source of it, to make a patch, and past the code in a file.
Like that :
REBOL []
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]
]
]
]
request-file/save/file %/C/test.txt
And, argh !
** Script Error: out has no value
** Where: request-file
** Near: if none? out start-out
What can I do to patch this function in 1.2.47 or older ?
Is there anybody here, who can explain me where is the problem ? Why
'out and 'fp var aren't set ?
Thanks.
Charles.