************************************************************ function File_Chooser * Description...... : Function invokes MS Common Dialog Control and * : returns an array of files via parameters list. * : Each element of the array contains one file... * Calling Samples...: dimension a_File[1] * : lcPath = "" * : lnFiles = File_Chooser(@a_File, @lcPath, DTitle, InDir) * Parameter List....: a_File, pPath, DTitle, InDir ******************************************************************** lparameter a_File, lcPath, DTitle, InDir external array a_File ** Definition of Common Dialog flags #define cdlOFNAllowMultiselect 0x200 *!* Specifies that the File Namelist box allows multiple selections. *!* The user can select more than one file at run time by pressing *!* the SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files. *!* When this is done, the FileName property returns a string containing the names *!* of all selected files. *!* The names in the string are delimited by spaces. local oDialog oDialog = createobject('MSComDlg.CommonDialog') * Set the flags for Multi-Select/Explorer with oDialog .MaxFileSize = 260 .Flags = 0x200 + 0x80000 .DialogTitle=DTitle * Set filters .filter = "All Files (*.*)|*.*|Database Files (*.dbf)|*.dbf|Index Files (*.cdx)|*.cdx" * Specify default filter .FilterIndex = 1 if not empty(m.InDir) .InitDir=m.InDir endif .ShowOpen * Save the file name to a variable lcFileName = .FileName endwith oDialog = null if empty(m.lcFileName) && User pressed a Cancel return 0 endif lnpt = at(chr(0), m.lcFileName) if lnpt > 0 lcPath = left(lcFileName, lnpt - 1) lcFileName = substr(lcFileName, lnpt + 1) lnFiles = occurs(chr(0), lcFileName) + 1 dimension a_File[lnfiles] lnI = 0 do while not empty(lcFileName) lnI = lnI + 1 lnpt = at(chr(0), lcFileName) if lnpt > 0 lcname = left(lcFileName, lnpt - 1) lcFileName = substr(lcFileName, lnpt + 1) else lcname = lcFileName lcFileName = "" endif a_File[lni] = lcname enddo lnFiles = alen(a_File, 1) *!* FOR lni = 1 TO lnlast *!* ? a_file[lni] *!* NEXT else lnFiles=1 dimension a_File[lnFiles] lnPos=rat('\',lcFileName) lcPath=left(lcFileName,lnPos-1) lcname=substr(lcFileName,lnPos+1) a_File[1] = lcname endif return lnFiles