Jump to content

Problem with browse and set data


Al Jones
 Share

Recommended Posts

The intent here is to allow the user to drop a file onto the input box (works), enter the directory and file name (works) or browse for the file - doesn't work.

This is all done on event - and most everything else works as I expect - a couple of minor quibbles but basically working.

This should be fairly straight forward but I've been banging my head against a brick wall. Went to the help and could see any reason why this didn't work

Func F1Browse()

$F1Source = "" ; the input box

$File = FileOpenDialog('Please choose file', '', 'All files (*.*)', 1)

; MsgBox(4096, "File",$file & " " & @error) ;just to make sure I've got the file and no error (I do & I don't)

GUICtrlSetData($F1Source, $File) ; set the F1Source to the retrieved file name.

; GUICtrlSetState($F1Source, 512) ; just an attempt from a sample - has no visible effect

EndFunc ;==>F1Browse

Obviously ( to me ) what I'm trying to do is place the result of FileOpenDialog into $F1Source and display the file name there. The file is found, placed into the $file var, placed int $f1Source (I can use it later) but it's not displayed for user verification.

What am I doing wrong - and I know this is gonna be something simple -- so shoot me now!

//al

Link to comment
Share on other sites

The intent here is to allow the user to drop a file onto the input box (works), enter the directory and file name (works) or browse for the file - doesn't work.

This is all done on event - and most everything else works as I expect - a couple of minor quibbles but basically working.

This should be fairly straight forward but I've been banging my head against a brick wall. Went to the help and could see any reason why this didn't work

Func F1Browse()

$F1Source = "" ; the input box

$File = FileOpenDialog('Please choose file', '', 'All files (*.*)', 1)

; MsgBox(4096, "File",$file & " " & @error) ;just to make sure I've got the file and no error (I do & I don't)

GUICtrlSetData($F1Source, $File) ; set the F1Source to the retrieved file name.

; GUICtrlSetState($F1Source, 512) ; just an attempt from a sample - has no visible effect

EndFunc ;==>F1Browse

Obviously ( to me ) what I'm trying to do is place the result of FileOpenDialog into $F1Source and display the file name there. The file is found, placed into the $file var, placed int $f1Source (I can use it later) but it's not displayed for user verification.

What am I doing wrong - and I know this is gonna be something simple -- so shoot me now!

//al

If $F1Source is a control then you nullified that with

$F1Source = ""

Comment out the line

$F1Source = "" ; the input box

or if you were just trying to clear any data then replace the same line with

GUICtrlSetData($F1Source, "")

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If $F1Source is a control then you nullified that with

$F1Source = ""

Comment out the line

$F1Source = "" ; the input box

or if you were just trying to clear any data then replace the same line with

GUICtrlSetData($F1Source, "")

I wasn't sure what setdata would do if there were anything already in the input box, and standard programming says to initialize the variable before you use it anyway. I knew it would be something simple - I think that will also take care of one of my other hiccups.

I've used AutoIt before for some screen handling (fill in the forms type stuff) this is the first 'real' progrm I'm trying with it. (But I've been programming since the early '70s).

Thank you much, sir.

//al

Link to comment
Share on other sites

I wasn't sure what setdata would do if there were anything already in the input box, and standard programming says to initialize the variable before you use it anyway.

First off it wouldn't matter if there was data already in the input, it would be replaced with the new string. You had already initialized the variable when you delared $F1Source = GUICtrlCreateInput(........)

Thank you much, sir.

//al

You're most welcome

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...