Sign in to follow this  
Followers 0
NateDJ

Having trouble with GUICtrlRead($ctrl) from second window.

3 posts in this topic

Ok, so I have a form with buttons, one opens another form with a list and a button. I want the button on the 2nd form to read the selected item from the list and act. when i click the button I get GUICtrlRead(^ ERROR ==> Variable used without being declared.

the ariables are all declared properly and everything but... still no luck. If i run it from the first window all is fine.

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <GUIListBox.au3>
#include <String.au3>
#include <Date.au3>
GUICreate("FileCopy",120,255,-1,-1,$WS_EX_TRANSPARENT,$WS_EX_TOPMOST)
$RepoManager = GUICtrlCreateButton("RepoManager", 0, 100, 117, 20)
$RepoManager = GUICtrlCreateButton("RepoManager", 0, 100, 117, 20)
GUICtrlSetOnEvent($RepoManager,"RepoManager")
Func RepoManager()
$RepoManagerWin = GUICreate("Repository Manager",125,255,-1,-1,$WS_EX_TRANSPARENT)
$CopyRepo = GUICtrlCreateButton("Copy",0,0,59,20)
GUICtrlSetOnEvent($CopyRepo,"CopyRepo")
$SelServer = GUICtrlCreateList("",0, 40,120,163)
GUICtrlSetData($SelServer, "R820")
GUICtrlSetData($SelServer, "R720")
GUISetState(@SW_SHOW,$RepoManagerWin)
   endif
EndFunc
Func CopyRepo()
   $repo = GUICtrlRead($SelServer) ;<============= ERROR is when reading this.
    msgbox(0,"Test", $repo)
GUIDelete()
EndFunc

This is as cut down as I can get it, any help is welcome.

Share this post


Link to post
Share on other sites



$SelServer is not properly declared since it is only declared in RepoManager() as a local variable.

You need to define them as Global variables preferably at the start of your script.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

LOL... wow yep :idiot: Been looking at this code way too long!

Thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0