Crotaphytus112 Posted April 4, 2011 Posted April 4, 2011 Hello there, I am having some trouble with the FileOpenDialog-function. I want to create a select-file-prompt where the user can select every file-type. I should be able to do it with this: $filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3) The prompt and everything works fine, but the problem is that it always seems to return successfull even when the user closes the dialog without chosing a file which obvoiusly causes problems later. But if I change the filter for file-types to .html or anything other than "all files", it works: $filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.html)", 3) So it would seem that using: "(*.*)" in the file-type filter always causes FileOpenDialog to return successfull or is it just me? Can I tell the FileOpenDialog to accept alle file-types in another way? Thanks!
AdmiralAlkex Posted April 4, 2011 Posted April 4, 2011 Hi and Welcome to the forums! I tested like this: $filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3) ConsoleWrite(@error & @CRLF) And it works for me, so before we can answer your question you need to post a reproducer (short fully working example) so we know what your exact question is. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Crotaphytus112 Posted April 6, 2011 Author Posted April 6, 2011 On 4/4/2011 at 8:50 AM, 'AdmiralAlkex said: Hi and Welcome to the forums! I tested like this: $filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3) ConsoleWrite(@error & @CRLF) And it works for me, so before we can answer your question you need to post a reproducer (short fully working example) so we know what your exact question is. Thanks for the warm welcome I think I have isolated the error, I am using Opt('MustDeclareVars', 1) in my script, like this: Opt('MustDeclareVars', 1) $filePath = FileOpenDialog("Choose your HTML-file to send", @ScriptDir & "", "(*.*)", 3) If @error Then MsgBox(0,"Error","No file chosen") Else MsgBox(0,"Succes","Succeeded loading HTML-file") EndIf It works if I remove Opt('MustDeclareVars', 1), but can I do that? Can I keep it and somehow declare @ScriptDir instead?
sahsanu Posted April 6, 2011 Posted April 6, 2011 On 4/6/2011 at 10:23 PM, 'Crotaphytus112 said: It works if I remove Opt('MustDeclareVars', 1), but can I do that? Can I keep it and somehow declare @ScriptDir instead? Then declare it... ;-) Global $filepath=...
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