REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 3-Aug-2010 Edit History |
Asks user to select a file and returns full file path (or block of paths).
Refinements:
/save - File save mode
/multi - Allows multiple file selection, returned as a block
/file
name [file!] - Default file name or directory
/title
text [string!] - Window title
/filter
list [block!] - Block of filters (filter-name filter)
See also:
Opens the standard operating system file requester to allow the user to select one or more files.
The line:
file: request-file
will open the file requester and return a single file name as a full file path. This is normally used to read or load files.
If the user clicks CANCEL or closes the file requestor, a NONE is returned.
To open the file requester to save a file:
file: request-file/save
This will change the text of the window to indicate that a save (write) will be done.
A default name can be provided for the file:
file: request-file/file %test.txt
This also works with the /save option, and a full path can be provided, in which case the requester will show the directory where the file will be found.
In addition, just a directory can be used:
file: request-file/file %/c/data/files/
Be sure to include the terminating slash to indicate a directory. Otherwise it will be treated as a file.
To allow the selection of multiple files at the same time:
files: request-file/multi foreach file files [print file]
The result is returned as a block, and each file within the block is a full path.
You can also provide file list filters to show only specific files. For example:
file: request-file/filter [ "REBOL Scripts" "*.r" "Text files" "*.txt" ]
The /title refinement lets you modify the window title for the file requester to help make it more clear to users.
file: request-file/save/title "Save your data file" either file [save file data] [print "data not saved"]
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |