In the Getting input from the user section in Chapter 3, Using Words, Values, and Types, we saw how to use ask to get user console input. Red also has special words that can be used to ask for a file or a folder.
Using request-file in the REPL or from a script pops up a dialog that prompts the user to select a file from the local file system:
In this screen, you can navigate to the file you need. Pressing the Open button returns the file name with its complete path as a file! ; choosing Cancel returns none. The result from the script is as follows:
;-- see Chapter07/ask-file.red:
file: request-file
probe file ;== %/E/Red/red.bat ; this file was chosen in File Explorer
In the same way, we have request-dir:
This gives us the following result when the Program Files map is chosen and the OK button pressed:
dir: request-dir
probe dir ...