Error getting tags :
error 404Error getting tags :
error 404 answer file | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
answer file
Basics
Expander triangle
Type
Command
Syntax

answer file[s] prompt [with defaultPath] [{with filter | of type} types] [titled windowTitle] [as sheet]

Introduced
1.0
Changed
2.6
Environment
Desktop,Web
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
Disk
Summary
Displays a standard file dialog for the user to select a file.
Examples

answer file "Select a file to delete:"
answer files "Select the files you wish to process:"
answer file "Input:" with "/Macintosh HD/"
answer file (field "Prompt") of type "RSTK"
answer file empty with filter "JPEGs,*.jpg"

Additional Comments
Expander triangle

Use the answer file command when a handler needs the file path of a file before continuing.

Parameters:

The prompt is a string (or any expression that evaluates to a string). If you specify empty, no prompt appears.

The defaultPath is the name and location of the folder whose contents are listed when the dialog box appears. If no defaultPath is specified, the dialog box lists the contents of the last folder you used with a file dialog box.

The windowTitle, if specified, appears in the title bar of the dialog box. If no windowTitle is given, the title bar is blank. (This parameter has no effect on Mac OS systems, because Mac OS file dialog boxes don't have a title bar.)

Use the types parameter to specify which files should appear and be available for selection.

Comments:

The dialog box displayed is the same one most programs use for the "Open" command in the File menu.

The absolute file path of the file the user chose is placed in the it variable. If the answer files form is used, a return-delimited list of such paths is placed in the it variable. If the user cancels the dialog, the it variable is set to empty, and the result function returns "Cancel".

Important! The answer file command does not open the file. It only displays the dialog box and retrieves the path to the file the user specifies.

If the as sheet form is used, the dialog box appears as a sheet on OS X systems. On other systems, the as sheet form has no effect and the dialog box appears normally. Attempting to open a sheet from within another sheet displays the second stack as a modal dialog box instead. To give a dialog box a prompt when using the as sheet form a non-empty title must be provided. This will cause the prompt to appear in the same place it would if as sheet was not being used.

If the systemFileSelector property is set to false, Revolution's built-in dialog box is used instead of the operating system's standard file dialog.

The way file types are specified depends on the platform:

Filtering for Mac OS: You can use either with filter or of type. With either form, the types parameter consists of one or more 4-characterfile types, concatenated. For example, to display text and PICT-formatfiles but no others, use a types parameter of "TEXTPICT". To display applications only, use a types parameter of "APPL".

If the types string is shorter than four characters (on a Mac OS system), the files are not filtered: all files appear in the dialog box.

Filtering for OS X: Works the same as filtering for Mac OS, except that if one of the file types is "APPL", the dialog box displays application bundles as well as single-file applications.

Filtering for Unix: You must use the with filter form if you want to specify one or more types: the of type form can't be used on Unix systems. The types parameter consists of a single wildcard expression.

Filtering for Windows: You must use the with filter form to specify one or more types: the of type form can't be used on Windows systems. A file type consists of an optional description, a line feed or comma, and one or more file extension specifications:

[description], *.extension [; *.extension...]

For example, to specify that only Revolution files should appear in the dialog box, use this statement. The description "Revolution files" is visible to the user at the bottom of the dialog, and only files with the extension ".rev" are shown:

answer file myPrompt with filter "Revolution files,*.rev"

You can specify more than one file extension for a single description. For example, to specify that only JPEG, GIF, and PNG files should appear, use this statement:

answer file myPrompt with filter "Web Graphics,*.jpg;*.gif;*.png"

You can include several descriptions, along with their file types, by separating them with commas. The descriptions appear in the list at the bottom of the file dialog box. For example, if you want to display all text and Microsoft Word files, use this command:

answer file myPrompt with filter "Text files,*.txt,MS Word files,*.doc"

Tip: If a set of filters is complex or if you use them in several places, it may be easier to put them into a variable, then use that variable in the answer file command.

Changes to Revolution:

The ability to use answer file...of type "APPL" to designate an OS X application bundle was introduced in version 2.0. In previous versions, the APPL file type showed only atomic files of type "APPL".

The answer file...as sheet form was introduced in version 2.0.

The answer files ... form was introduced in version 2.6.

User Comments
Expander triangle
User thumbnail
mypubacct@gmail.com
StarStarStarStarStar
Oct 21, 2009
According to this post ( http://lists.runrev.com/pipermail/use-revolution/2009-August/126806.html ) the "with filter" form is depricated. It does not work in OS X (10.5.8). Use the "with type" form instead. For example, this does not work:

answer file "Select the text file" with filter "Text File,*.txt"

But this does work:

answer file "Select the text file" with type "Text|txt"