Kidney Posted May 15, 2012 Posted May 15, 2012 hey guys, in vb there is a thing called a structure that allows you to create multiple objects in a structure (like an array) but with different data types. i am currently working on a project that creates a form with a list box and then a group box with multiple drop down menus and radio buttons. the group box also has an "Add" button that i want to store all the selected data from the drop down boxes and create an item in the List box. Once that is done, i would also like to be able to click on an item in the list box and then click the "Edit" button and have that item populate the drop down menus so that it can be edited. here is the code i have so far for the GUI: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $List2= "---None---|L1Item1|L1Item2|L1Item3|L1Item4|L1Item5" $List1= "---None---|L2Item1|L2Item2|L2Item3|L2Item4|L2Item5" $MissionList = "Mission 1|Mission 2|Mission 3|Mission 4|Mission 5" $GradeList = "Default (Highest Available)|Grade 1|Grade 2|Grade 3|Grade 4|Grade 5" #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1", 623, 436, 192, 132) $List1 = GUICtrlCreateList("", 32, 24, 273, 134) $btnRemove = GUICtrlCreateButton("Remove", 320, 72, 81, 33, $WS_GROUP) $grpCrewMember = GUICtrlCreateGroup("Crew Member", 24, 168, 585, 257) $cbxCrewName = GUICtrlCreateCombo("", 48, 224, 241, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GuiCtrlSetData(-1, $List2, "") $cbxSkill = GUICtrlCreateCombo("", 48, 280, 177, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GuiCtrlSetData(-1, $MissionList, "") GUICtrlSetState(-1, $GUI_DISABLE) $cbxMissionGrade = GUICtrlCreateCombo("", 272, 296, 190, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GuiCtrlSetData(-1, $GradeList, "") GUICtrlSetState(-1, $GUI_DISABLE) $cbxMission = GUICtrlCreateCombo("", 48, 336, 177, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $Label1 = GUICtrlCreateLabel("Name:", 56, 200, 44, 20) $Label2 = GUICtrlCreateLabel("Skill:", 56, 256, 32, 20) $Label3 = GUICtrlCreateLabel("Mission:", 56, 312, 53, 20) $Label4 = GUICtrlCreateLabel("Mission Grade:", 288, 272, 94, 20) $rdbDarkDiplo = GUICtrlCreateRadio("Dark Diplo", 280, 336, 113, 17) GUICtrlSetState(-1, $GUI_DISABLE) $rdbLightDiplo = GUICtrlCreateRadio("Light Diplo", 280, 360, 113, 17) GUICtrlSetState(-1, $GUI_DISABLE) $rdbDilpoOff = GUICtrlCreateRadio("Diplo Off", 280, 384, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $brnAdd = GUICtrlCreateButton("Add", 488, 328, 81, 41, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) $grpAlliance = GUICtrlCreateGroup("Alliance", 304, 192, 217, 65) $rdbLeft = GUICtrlCreateRadio("Left", 312, 224, 89, 17) GUICtrlSetState(-1, $GUI_CHECKED) $rdbRight = GUICtrlCreateRadio("Right", 424, 224, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) $btnSave = GUICtrlCreateButton("Save", 448, 32, 89, 33, $WS_GROUP) $btnLoad = GUICtrlCreateButton("Load", 448, 88, 89, 33, $WS_GROUP) $btnNewMember = GUICtrlCreateButton("New", 320, 24, 81, 33, $WS_GROUP) $btnEdit = GUICtrlCreateButton("Edit", 320, 120, 81, 33, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $btnSave Case $nMsg = $rdbRight ResetField() Case $nMsg = $rdbLeft ResetField() Case $nMsg = $cbxCrewName If GUICtrlRead($cbxCrewName) <> "---None---" Then GUICtrlSetState($cbxSkill, $GUI_ENABLE) Else GUICtrlSetState($cbxSkill, $GUI_DISABlE) EndIf Case $nMsg = $cbxSkill If GUICtrlRead($cbxSkill) = "Diplomacy" Then GUICtrlSetState($rdbDarkDiplo, $GUI_ENABLE) GUICtrlSetState($rdbLightDiplo, $GUI_ENABLE) Else GUICtrlSetState($rdbDarkDiplo, $GUI_DISABlE) GUICtrlSetState($rdbLightDiplo, $GUI_DISABlE) GUICtrlSetState($rdbDilpoOff, $GUI_CHECKED) EndIf GUICtrlSetState($cbxMissionGrade, $GUI_ENABLE) EndSelect WEnd Func ResetField() If GUICtrlRead($rdbRight) = $GUI_CHECKED Then GUICtrlSetData($cbxCrewName, "","") GuiCtrlSetData($cbxCrewName, $List1, "") Else GUICtrlSetData($cbxCrewName, "","") GuiCtrlSetData($cbxCrewName, $List2, "") EndIf GUICtrlSetData($cbxSkill, "","") GUICtrlSetData($cbxSkill, $MissionList,"") GUICtrlSetState($cbxSkill, $GUI_DISABlE) GUICtrlSetState($rdbDarkDiplo, $GUI_DISABLE) GUICtrlSetState($rdbLightDiplo, $GUI_DISABLE) GUICtrlSetState($rdbDilpoOff, $GUI_CHECKED) GuiCtrlSetData($cbxMissionGrade, "", "") GuiCtrlSetData($cbxMissionGrade, $GradeList, "") GUICtrlSetState($cbxMissionGrade, $GUI_DISABLE) EndFunc So my Question really is, is there an easy way to store all of these variables into some type of structure?? or is there only arrays??
czardas Posted May 16, 2012 Posted May 16, 2012 (edited) I don't know enough about VB structures to answer this question, but I can tell you that although it is advised to avoid mixing data types within arrays in AutoIt, it generally doesn't seem to cause any problems until you start trying to create arrays of arrays (this is pointless anyway because you can have up to 64 dimensions). I am also aware that there are some alternatives to using arrays.but I'm not sure if they are suitable for your purpose. Edited May 16, 2012 by czardas operator64 ArrayWorkshop
shanet Posted May 16, 2012 Posted May 16, 2012 Kidney, I am not sure on the specifics of vb structures, so my short answer would be yes. My longer answer would be this: In object oriented languages such as C++ and (as I believe), VB, you may create classes where you may have member data and functions. In C (Not C++), you may have structures. These are sort of like classes, without the functions. AutoIt supports c-style structures - that is you can create a structure, but not a class. Here is an example: struct myStruct { int first; DWORD second; unsigned short third; } There is the c-style struct. Its AutoIt alternative is: $myStruct = DllStructCreate('int;dword;ushort') You can find out more about DllStructs on the forums. [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
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