Selecting a file or folder

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-fileprobe file          ;== ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.