Vindicator209 Posted June 8, 2007 Posted June 8, 2007 hehe, I've never dealt with arrays, and im trying to continously add to a combo box from arrays the user declares, but im having trouble making a loop that does it until theres no more existing arrays (and yes, I dont have any Idea what im talking about) Func ComboBox($cTitle,$cText,$cButtonText,$cX,$cY) GUICreate($cTitle, 193, 167, $cX, $cY) $cCombo = GUICtrlCreateCombo("", 10, 136, 140, 25) $cButton = GUICtrlCreateButton($cButtonText, 150, 136, 30, 25) GUICtrlCreateLabel($cText, 10, 10, 169, 121) GUISetState(@SW_SHOW) $i=0 Do ;Problem Area GUICtrlSetData($cCombo,$ComboAdd[$i],GUICtrlRead($cCombo)) $i=$i+1 Until @error = 1 ;erm... this is my try at it While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $cButton Return(GUICtrlRead($cCombo)) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
Vindicator209 Posted June 8, 2007 Author Posted June 8, 2007 ok I guess I'll clear i up a bit: Local $ComboAdd[4];truthfully, I dont know what this does $ComboAdd[0] = "ONE" $ComboAdd[1] = "TWO" $ComboAdd[2] = "1" $ComboAdd[3] = "2" ComboBox("Test","Hey!","Ok",-1,-1) Func ComboBox($cTitle,$cText,$cButtonText,$cX,$cY) GUICreate($cTitle, 193, 167, $cX, $cY) $cCombo = GUICtrlCreateCombo("", 10, 136, 140, 25) $cButton = GUICtrlCreateButton($cButtonText, 150, 136, 30, 25) GUICtrlCreateLabel($cText, 10, 10, 169, 121) GUISetState(@SW_SHOW) $i=0 Do;Problem Area GUICtrlSetData($cCombo,$ComboAdd[$i],GUICtrlRead($cCombo)) $i=$i+1 Until @error = 1;erm... this is my try at it While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $cButton Return(GUICtrlRead($cCombo)) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc Array variable has incorrect number of subscripts or subscript dimension range exceeded [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
McGod Posted June 8, 2007 Posted June 8, 2007 Local $ComboAdd[4];truthfully, I dont know what this does This declares an array, the [4] is the number of subscripts it has. [0] [1] [2] [3] Theres your 4. When you add to it you need to do a ReDim $Vari[uBound($Vari)+1] In your case ReDim $ComboAdd[uBound($ComboAdd)+1] [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u]
Vindicator209 Posted June 8, 2007 Author Posted June 8, 2007 (edited) now how do I stop it after the arrays dont exist anymore? Do Sleep(100) GUICtrlSetData($cCombo,$ComboAdd[$i]) ReDim $ComboAdd[uBound($ComboAdd)+1] Until <===============I don't know how to stop it I tried @error = 1 but there appearently no error when it tries to use a non existant array... Edited June 8, 2007 by MethodZero [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
randallc Posted June 8, 2007 Posted June 8, 2007 (edited) now how do I stop it after the arrays dont exist anymore? Do Sleep(100) GUICtrlSetData($cCombo,$ComboAdd[$i]) ReDim $ComboAdd[uBound($ComboAdd)+1] Until <===============I don't know how to stop it I tried @error = 1 but there appearently no error when it tries to use a non existant array...Hi, try ;ComboAdd.au3 #include <GUIConstants.au3> Local $ComboAdd[4];dimension of the array (number of elements) $ComboAdd[0] = "ONE" $ComboAdd[1] = "TWO" $ComboAdd[2] = "1" $ComboAdd[3] = "2" ComboBox("Test", "Hey!", "Ok", -1, -1) Func ComboBox($cTitle, $cText, $cButtonText, $cX, $cY) GUICreate($cTitle, 193, 167, $cX, $cY) $cCombo = GUICtrlCreateCombo($ComboAdd[0], 10, 136, 140, 25) $cButton = GUICtrlCreateButton($cButtonText, 150, 136, 30, 25) GUICtrlCreateLabel($cText, 10, 10, 169, 121) GUISetState(@SW_SHOW) $i = 0 For $sArrayElement In $ComboAdd GUICtrlSetData($cCombo, $sArrayElement, GUICtrlRead($cCombo)) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $cButton Return (GUICtrlRead($cCombo)) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>ComboBoxRandall Edited June 8, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Vindicator209 Posted June 8, 2007 Author Posted June 8, 2007 thanks very very very very much! Both of you, thank you! [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
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