Clipper34 Posted May 8, 2008 Share Posted May 8, 2008 (edited) Hey guys, i have a question. Here in the code below $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" $file = FileSaveDialog("Choose a name:", $MyDocsFolder, "Text files(*.txt)", 16) If $file = 1 Then FileSaveDialog("Choose a name:", $MyDocsFolder, "Text files(*.txt)", 16) MsgBox(0, "!", "File saved!") EndIf on line 2 at the end after (*.txt)", is 16 and i'm wondering if you can use an if statement for an InputBox comes up to ask you if you wish to overwrite the file. Thanks Edited May 8, 2008 by Clipper34 Link to comment Share on other sites More sharing options...
MikeP Posted May 8, 2008 Share Posted May 8, 2008 (edited) Hi. I think you're confusing .. or I'm having hard times understanding what you want to do. If you put a 16.. then the user will be promped to overwrite if the file already exists.. if you don't put it..then there won't be a warning message. your 'If $file = 1' doesn't make sense.. $file is the full path of the file chosen to be saved.. $file is something like that : "C:\Test\mytextfile.txt" Edited May 8, 2008 by MikeP Link to comment Share on other sites More sharing options...
Clipper34 Posted May 8, 2008 Author Share Posted May 8, 2008 Below is an example of the FileSaveDialog function. FileSaveDialog ( "title", "init dir", "filter" [, options [, "default name"]] ) And this again options [optional] 2 = Path Must Exist (if user types a path, ending with a backslash) 16 = Prompt to OverWrite File And i'm wondering if you can use a serperate if statement to have an prompt for overwriting a file. Link to comment Share on other sites More sharing options...
MikeP Posted May 8, 2008 Share Posted May 8, 2008 $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" While 1 $saveOption = InputBox("","Do you wish to be asked to overwrite files (yes/no)?") If $saveOption = "yes" OR $saveOption = "no" Then ExitLoop Else MsgBox(0,"", "Choose yes or no please") EndIf WEnd If $saveOption = "yes" Then $saveOption = 16 Else $saveOption = "" EndIf $file = FileSaveDialog("Choose a name:", $MyDocsFolder, "Text files(*.txt)", $saveOption) Link to comment Share on other sites More sharing options...
Clipper34 Posted May 8, 2008 Author Share Posted May 8, 2008 Thanks MikeP i greatly appreciate the help. Link to comment Share on other sites More sharing options...
ResNullius Posted May 8, 2008 Share Posted May 8, 2008 Another way that asks after the Save dialog is opened and prevents a double prompt (one from your input box, and again from the Save with 16 $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" $file = FileSaveDialog("Choose a name:", $MyDocsFolder, "Text files(*.txt)") If FileExists($file) then $saveOption = InputBox("","The file already exists." & @CRLF & "Do you wish to overwrite it (yes/no)?") If StringUpper($saveOption) = "YES" then ;file saving stuff here with overwrite Else ;loop back to file save function or cancel here EndIf EndIf Link to comment Share on other sites More sharing options...
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