Sarah Reichelt wrote:
The "answer file" command usually gets me thoroughly confused, but
this time, I'm not sure it is able to do what I want.
I want to allow the user to select a text file, but it has to be a
text file with a name like "Slot45.txt". The number will vary, but it
has to start with "Slot" and have the ".txt".
As has been noted here, filtering for prefixes is a lot harder than
filtering for suffixes. The former is too prone to user error, while
the latter is what the system expects. "Go with the grain", as they say.
Mark Waddingham did an *excellent* reworking of the answer file command
for v2.6.1, and since then it offer unprecedented flexibility which
works on all platforms without branching statements -- from the Dictionary:
Syntax
answer file[s] prompt [with defaultPath] [with type types \
[or type types ...]] [titled windowTitle] [as sheet]
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") with type "Revolution Stacks|rev|RSTK"
-- shows stacks
answer files "Select the images you wish to view:" with \
type "JPEG Images|jpg|JPEG" \
or type "GIF Images|gif|GIFf" \
or type "All Images|jpg,gif|JPEG,GIFf"
So in your case you could support a suffix like "tsv" and ALSO support
"txt" and all:
answer files "Select a file:" with type "Tab-Separated|tsv|TEXT" \
or type "Text Files|txt|TEXT" \
or type "All Files"
This will present the user on any supported platform with a standard
GetFile dialog with an option control at the top which lets them choose
between filtering for Tab-Separated, Text Files, or All Files, with the
first one ("Tab Separated") as the default.
I LOVE this new "answer file with type" option, and have been replacing
all of my older "answer file" calls with this new form to allow smooth
support on both Mac and Win without having to check the platform and
using "...with filter..." or "...of type..." for each one separately.
Thank you Mark!
--
Richard Gaskin
Managing Editor, revJournal
_______________________________________________________
Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution