rdwray Posted December 10, 2010 Share Posted December 10, 2010 Why does this happen and is there a way to create the array of pointers.? Thanks...F:\Backup\AutoItV3\test.au3 (27) : ==> Expected a "=" operator in assignment statement.: $aCtrl[1] = GUICtrlCreateButton("Button Test", 0, -1) $aCtrl^ ERROR “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther Link to comment Share on other sites More sharing options...
wakillon Posted December 10, 2010 Share Posted December 10, 2010 Is $aCtrl declared before Like this : Global $aCtrl[2] ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
rdwray Posted December 10, 2010 Author Share Posted December 10, 2010 yes. The entire code:#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Global $aCtrl[2] Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $aCtrl[0] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aCtrl[1] = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $aCtrl[0] Run('Notepad.exe') ; Will Run/Open Notepad Case $aCtrl[1] MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSwitch WEnd EndFunc ;==>Example “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther Link to comment Share on other sites More sharing options...
SadBunny Posted December 10, 2010 Share Posted December 10, 2010 (edited) Easy: change Example() Global $aCtrl[2] ... to: Global $aCtrl[2] Example() /edit: still, this error is everything but indicative... Edited December 10, 2010 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 10, 2010 Share Posted December 10, 2010 You declare the Global variable $aCtrl AFTER the function call, so it hasn't been seen by the script yet, so your array variable isn't declared. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rdwray Posted December 10, 2010 Author Share Posted December 10, 2010 Easy: change Example() Global $aCtrl[2] ... to: Global $aCtrl[2] Example() /edit: still, this error is everything but indicative... Returned same error:F:\Backup\AutoItV3\test.au3 (26) : ==> Expected a "=" operator in assignment statement.: $aCtrl[0] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aCtrl^ ERROR “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther Link to comment Share on other sites More sharing options...
Realm Posted December 10, 2010 Share Posted December 10, 2010 (edited) Hello rdwray,Actually, I don't see the array declared. I see controls assigned to an array.You have to declare an array with its size before using it.#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Global $aCtrl[2] Func Example() Local $Button_1, $Button_2, $msg Local $aCtrl[2] ;Declare arrays like this or with Dim, Global GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $aCtrl[0] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aCtrl[1] = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $aCtrl[0] Run('Notepad.exe') ; Will Run/Open Notepad Case $aCtrl[1] MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSwitch WEnd EndFunc ;==>ExampleRealmEdit: This worked for meEdit: I overlooked where you had declared it, I was expecting it inside the functions, sorry. moving the declaration above the call for the function should work for you#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $aCtrl[2] Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $aCtrl[0] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aCtrl[1] = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $aCtrl[0] Run('Notepad.exe') ; Will Run/Open Notepad Case $aCtrl[1] MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSwitch WEnd EndFunc ;==>Example Edited December 10, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
SadBunny Posted December 10, 2010 Share Posted December 10, 2010 Are you sure? I copypasted your script and only changed the order of those two lines. That works perfectly here... #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $aCtrl[2] Example() Func Example() Local $Button_1, $Button_2, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $aCtrl[0] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aCtrl[1] = GUICtrlCreateButton("Button Test", 0, -1) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $aCtrl[0] Run('Notepad.exe') ; Will Run/Open Notepad Case $aCtrl[1] MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed EndSwitch WEnd EndFunc ;==>Example Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
rdwray Posted December 10, 2010 Author Share Posted December 10, 2010 You declare the Global variable $aCtrl AFTER the function call, so it hasn't been seen by the script yet, so your array variable isn't declared.When you are having a bad day, you want eveyone to join you. Thanks... “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther Link to comment Share on other sites More sharing options...
BrewManNH Posted December 10, 2010 Share Posted December 10, 2010 Returned same error:F:\Backup\AutoItV3\test.au3 (26) : ==> Expected a "=" operator in assignment statement.: $aCtrl[0] = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $aCtrl^ ERROR That's odd, because I came up with the same solution and it worked for me. If you move the declaration statement above the Example() line in the code, I get no errors. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
BrewManNH Posted December 10, 2010 Share Posted December 10, 2010 @SadBunny seems like we're crossing paths today in here If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rdwray Posted December 10, 2010 Author Share Posted December 10, 2010 Spammer, you were right, it is working. Our messages are getting posted in the wrong order. “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther 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