Presenting successive file names in 'Open'
graham.samuel at blueyonder.co.uk
Wed Dec 1 18:00:17 EST 2004
Thanks all who replied so quickly (two Franks, Chipp, Rob and Alex!
I may have misled some readers by my example where the files were
called A01, A02 etc - this was just an example. In fact they're just
the titles of text files that need a certain kind of conversion: the
titles reflect the contents and aren't really a numerically complete
set. Also, I didn't want to open the file for the user, since in some
cases he/she might choose to skip it. What I wanted to do was to point
directly at the file to prevent all that tedious scrolling which one
gets in OS 'open' dialogs that don't remember the last file you opened
but just start at the top of the list again. As far as I remember, Mac
OSX is worse at this than OS9 was.
This is why Alex's idea would work best for me if I could make it work:
>> 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,
>>> 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
>> a folder.
>> Thus, for example,
>> answer file "Test" with "D:/Our
>> opens the dialog at the correct folder, with the file "Boggal"
>> 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 :-)
The trouble is, my version of this code displays the right folder and
within it the usual scrolling file list (this is OSX) but it doesn't
preselect the file. Strange, since it worked for Alex, but I have quite
carefully tested that my equivalent of his 'theDefault' is the complete
path to the last file read (I've not yet reached the refinement of
picking the actual next file).
I guess I may have to go back to one of the private-list based
Graham Samuel / The Living Fossil Co. / UK and France
More information about the use-livecode