RadAct Posted October 6, 2021 Posted October 6, 2021 Hi. I'm trying to get FileOpenDialog to return the number of files selected rather than displaying the filename themselves as per the default example in the help file. eg. How many zip files were selected by the dialog box. eg. Local $sFileOpenDialog = FileOpenDialog($sMessage, $sourcefolder & "\", "Zip (*.zip;*.rar)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) Local $sFileOpenDialog = FileOpenDialog($sMessage, $sourcefolder & "\", "Zip (*.zip;*.rar)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) Local $files = _FileListToArray($sFileOpenDialog, "*", 1) Local $count = $files[0] I get the following error: ==> Subscript used on non-accessible variable.: Global $filecount = $files[0] Global $filecount = $files^ ERROR How do you access that first part of the array as per the help file? Return Value Success: A one-dimensional array. $aArray[0] = Number of Files\Folders returned $aArray[1] = 1st File\Folder $aArray[2] = 2nd File\Folder $aArray[3] = 3rd File\Folder $aArray[n] = nth File\Folder
Danp2 Posted October 6, 2021 Posted October 6, 2021 I don't think you want to use _FileListToArray here. Instead take a look at StringReplace or StringSplit. Latest Webdriver UDF Release Webdriver Wiki FAQs
Solution BigDaddyO Posted October 6, 2021 Solution Posted October 6, 2021 $count = 0 Local $sFileOpenDialog = FileOpenDialog($sMessage, $sourcefolder & "\", "Zip (*.zip;*.rar)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) If Not @error Then StringReplace($sFileOpenDialog, "|", "") Local $count = @extended If $count < 1 Then $count = 1 EndIf MsgBox(0, "Selected", $count)
AlessandroAvolio Posted October 6, 2021 Posted October 6, 2021 @RadAct FileOpenDialog: https://www.autoitscript.com/autoit3/docs/functions/FileOpenDialog.htm Return Value Success: the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|...". StringReplace: https://www.autoitscript.com/autoit3/docs/functions/StringReplace.htm Return Value Returns the new string with the number of replacements performed stored in the @extended macro. Example: StringReplace("Directory|file1|file2|file3|file4", "file", "file") and you find number of files after in @extended
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now