At 16:53 01/12/2004 +0000, Graham Samuel wrote:
Folks
I'm not sure how to approach this problem:
I want a user to see the contents of a series of text files, all in the same folder. Let's say the files are called A01,A02... G99 or something like that. The sequence of operations is -
1. The user is offered a normal 'open' dialog to select a file, initially navigating to the folder in question and picking A01 to read.
2. The user looks at the file, does some action and disposes of it.
3. The user usually then wishes to look at the next file in the alphabetical sequence (A02 in my example, but it might be any text string). Clearly she/he can navigate to this name by:
a) remembering the name of the last file looked at;
b) scrolling down to the file below the last file looked at in the normal 'open' dialog
If there are a lot of files, this scrolling becomes tedious on most OSs (e.g in OSX the OS 'open' dialog doesn't hilite the last file read, nor does it scroll down to it), so I would prefer to propose the name of the next file in the sequence in the 'open' dialog for the user to accept or reject.
What would be the best way to do this? So far I've only thought of traversing the folder somehow before the user starts work, and putting all the file names in a list field for the user to pick from. Seems kind of overkill, though.
This is actually much easier than you might think ....
The docs for "answer file" say
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.
But in fact, the defaultPath can be the name and location of A FILE within a folder.
Thus, for example,
answer file "Test" with "D:/Our Documents/Alex/RunRev/Boggal.rev"
opens the dialog at the correct folder, with the file "Boggal" pre-selected.
So you can allow the user to open the first file as normal, then on subsequent opens, do something like
set itemDel to "/"
put item 1 to -2 of lastFile into theFolder
put item -1 of lastFile into theName
put theFolder & "/" into theDefault
if lastFile <> "" then
set the defaultfolder to theFolder
put the short files into fList
sort flist
set wholeMatches to true
put lineOffset(theName, fList) into t
if t > 0 then
put item -1 of line (t+1) of fList after theDefault
end if
end if
answer file "Your Prompt" with theDefault
put it into lastFile
(I'm sure you could re-write that code fragment into something neater - but it does work :-)
-- Alex.
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
