$msfile Opens dialog to select 1 or more files.
Contents
Synopsis
- $msfile(<path> [,title [,OpenButtonText] ] ) Opens dialog to choose 1 or multiple files. Returns N where N>=0 is the number of selected files, N=-1 if too many files selected.
- $msfile(N) After dialog closes, for N>=1 returns the Nth selected filename. For N=0 returns the same value as returning by the identifier closing the dialog, the count of selected files.
Parameters
- path Starting folder for the file select dialog. Can be a relative path to $mircdir. Ignores the last "\" delimited token if path doesn't end with "\" or "/".
- title Optional string placed in the titlebar of the select dialog
- OpenButtonText Optional string to replace 'Open' on that button of the select dialog. You cannot set this parameter without first defining the the title parameter to a non-null string.
- N When N>=1, returns the Nth selected filename N=0 is the total number of files selected.
Properties
None
Local Identifier
$sfstate Returns the null string or 'cancel' or 'error' after exiting the dialog.
Example
//echo -ag $msfile($sysdir(profile),This shows in Titlebar,OpEn) $sfstate | var %i 0 | echo -ag sfstate $sfstate | while (%i < $msfile(0)) { inc %i | echo -ag %i / $msfile(%i) }
The 2nd parameter puts your optional string in the titlebar. The 3rd optional parameter alters the label on the 'Open' button.
If you press ESCAPE or click cancel, the identifier returns 0 because zero files were selected. $msfile(0) is also filled with the same value, the number of files selected. Also, the local $sfstate identifier is filled with the string 'cancel'.
You can select multiple files and/or folders by pressing the Control key while clicking on filenames in the dialog. If the 1st (or only) item selected is a folder, clicking 'open' (or double-clicking on the folder) navigates into that folder.
Otherwise, folders are ignored in the returned count and list of filenames returned. You can also select a range of filenames by single-clicking on a file, then hold down the shift-key while clicking on a different file. All files in that range will be selected. If the Control key is pressed while you click on the 1st file in that range, you can select that range without losing the earlier selection(s).
If you double-click on a file, the dialog behaves as if you selected that file and then pressed the OPEN button, returning that filename as $msfile(1). If you double-click on a file while pressing the Control key and while other files are already selected, any prior selections are not cleared, returning values as if you clicked OPEN while those multiple files are selected.
If your first selection is a folder, the dialog navigates into that folder for selecting files there, clearing all files selected in the original folder. If your first selection is a filename, the identifier and $msfile(0) both return the number of selected files. It doesn't matter which order you click on files, because the returned files are filled into $msfile(N) in the order they appear in the dialog window, which could be sorted by filename, size, etc in normal or reverse order.
Once you've clicked anywhere within the dialog to set the focus there, even if you haven't selected a file, you can then press Control-A within the dialog, and it selects all the files before selecting all the folders, and $msfile(N) is filled in the dialog's sort order.
Compatibility
Added: mIRC v6.1
Added on: 29 Aug 2003
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.