Jump to content

FileSaveDialog and multiple filter groups


toofat
 Share

Recommended Posts

$SavePath = FileSaveDialog ('Save File', @DesktopDir, 'Text files (*.txt)|Webpage (*.htm)', 16, 'Any name')

I have searched the forum and found that many users have the same problem. How to find out which filter of multiple filters did the user select? Any such question has been left unanswered. So please if someone from AutoIt team can answer this. If this is not possible then what is a point of multiple filter groups in FileSaveDialog? Maybe i'm wrong. Maybe I'm doing something wrong. Maybe this is not possible. Maybe this is a bug. Any answer would be appreciated.

P.S.

Sorry for bad spelling if any.

Link to comment
Share on other sites

OK, It didn't work but now I have even more questions. I use AutoIt v3.2.0.1.

1. What is this function "stringregexp" (looked in help but there is NO SUCH FUNCTION)

2. In the first pass it returned "5"

3. In second pass it returned

If Not @error then $ext=$ext[0]
If Not @error then $ext=$ext^ERROR
Error: Subscript used with non-Array variable

Numbers 2. and 3. are not very important. I will figure them out just if someone would tell me what is this function "stringregexp". What it does and what are the parameters ... If this is user defined function then please tell me which file should I include ...

Link to comment
Share on other sites

OK I get it, at least the StringRegExp part. I downloaded beta but your expression still returns 1 every time or "Array is invalid. No matches." and I think I know why. Because you think that FileSaveDialog returns the path + filter user selected, but it doesn't. It returns just the path part and that is a root of my problem in the first place. That is why I think that having multiple filter groups in FileSaveDialog is point-less. You can have as much filters as you want and none of them will never be included as part of the return variable. If you compare the help for FileOpenDialog and FileSaveDialog they are pratically the same, but filters for FileSaveDialog function is much more important because it gives you the answer how you should format the output file (txt and html are very diferent dahhh...). And AutoIt fails here because if user, for instance wants to save file as "C:\index" with extension "html", you would expect return variable to be "C:\index.html" or at least as an array, something like this array[1]="C:\index", array[2]="html", but what AutoIt does is return just the path portion "C:\index", extension portion is never passed on. So, am I wrong, stupid or what? Maybe my conclusion is wrong, maybe I am doing something wrong. Once again, please HELP.

Link to comment
Share on other sites

OK I get it, at least the StringRegExp part. I downloaded beta but your expression still returns 1 every time or "Array is invalid. No matches." and I think I know why. Because you think that FileSaveDialog returns the path + filter user selected, but it doesn't. It returns just the path part and that is a root of my problem in the first place. That is why I think that having multiple filter groups in FileSaveDialog is point-less. You can have as much filters as you want and none of them will never be included as part of the return variable. If you compare the help for FileOpenDialog and FileSaveDialog they are pratically the same, but filters for FileSaveDialog function is much more important because it gives you the answer how you should format the output file (txt and html are very diferent dahhh...). And AutoIt fails here because if user, for instance wants to save file as "C:\index" with extension "html", you would expect return variable to be "C:\index.html" or at least as an array, something like this array[1]="C:\index", array[2]="html", but what AutoIt does is return just the path portion "C:\index", extension portion is never passed on. So, am I wrong, stupid or what? Maybe my conclusion is wrong, maybe I am doing something wrong. Once again, please HELP.

you're completely correct. That is very stupid, the way FileSaveDialog works. Might want to wait till a dev sees this and maybe he can tell us why...

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

example of a workaround

#include <File.au3>
Global $null
$path = _PathSplit(FileSaveDialog("Save It","","Text and HTML ONLY(*.txt;*.html)"),$null,$null,$null,$null)
If $path[4] = ".txt" Or $path[4] = ".html" Then
    MsgBox(0,"Sucess","Sucessfuly saved, thanks for following directions")
Else
    MsgBox(0,"Error","Ok wise guy what didnt you understand about txt or html only?")   
EndIf
Link to comment
Share on other sites

Thatsgreat2345 you never worked in IT help desk did you? Users are stupid. It's like Murphy. If they can find a way to F*** UP they will. You can NEVER relly on that they will input in the FileSaveDialog full path with extension (eg. "C:\index.html") they will always browse to the "C:\", input the name "index" and select the extension from a list of available filters.

Link to comment
Share on other sites

Success: Returns the full path of the file chosen. Results for multiple selections are "Directory|file1|file2|..."

where is this extension?

My point exactly. Also ther is no sense in this " Results for multiple selections". What multiple selections? Its like someone rewrote the "SUCCESS" option from FileOpenDialog.

Link to comment
Share on other sites

lol calm down calm down and yes i have worked at a help desk , called Autoit Forums where people come to get help when they could easily be achieve with a work around lol, dude as i suggested make ur own fileopendialog , use filereadtoarray simple :P, and smoke made a UDF to get every file even in subfolders so it shouldnt be to hard, and are you like marketing this program or something?

Edited by Thatsgreat2345
Link to comment
Share on other sites

u could make ur own filesavedialog just a suggestion , or have a u forgot to apply an extension which would u like to choose kinda thing

Yes I could. I could also learn how to program in C++. I could also be a president of Burundi (no I'm not from Burundi), but I'm not. Only thing that I want is that FileSaveDialog would work like it is supposed to.
Link to comment
Share on other sites

I will see if I can rewrite FileSave dialog and have it return an extension. I think it's a standard windows function, so a trip to MSDN will probably solve the problem.

I'll post back with my results (if I do actually get it working)

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Take a look at this thread

http://www.autoitscript.com/forum/index.php?showtopic=35999

The advantage of the UDF posted by Amel27 (Post #11, part way down the page) is that it has the ability to open the File Open or File Save dialog as a standard child to a parent GUI. I bet that if you asked him, Amel27 could incorporate a feature to return the file extension into his UDF (it may already be there, but I have only used his File Open Dialog implementation...

Edited by improbability_paradox
Link to comment
Share on other sites

improbability_paradox I will take a look just as soon as I return home. My girlfrend will kill me. We are just packing for a skeing (spelling, you now snow, fun and that crap) trip. We return after New Year. If I write another line I'm dead. Merry Christmas everyone and thanks for all the help.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...