Search the Community
Showing results for tags 'dynamic array'.
-
Hey all, I'm working on a script to read in values and write them to an array which increases with size as values are added from a GUI three at a time. at this time, I have the following script. #include <GUIConstantsEx.au3> #include <Array.au3> main() Func saveData($arr, $newData) If IsArray($arr) = 1 Then $Bound = UBound($arr) ReDim $arr[$Bound+1] $arr[$Bound] = $newData Else Dim $arr[1] $arr[0] = $newData EndIf ; _ArrayDisplay($arr) Return $arr EndFunc Func main() dim $arr1; $oForm1 = GUICreate("Form1", 623, 226, 192, 114) $Input1 = GUICtrlCreateInput("X Value", 8, 8, 177, 21) $Input2 = GUICtrlCreateInput("Y Value", 264, 8, 129, 21) $Input3 = GUICtrlCreateInput("Z Value", 496, 8, 121, 21) $Button1 = GUICtrlCreateButton("Save and Continue", 8, 187, 137, 16) $Button2 = GUICtrlCreateButton("Save and Print", 152, 187, 145, 16) $Button3 = GUICtrlCreateButton("Cancel and Print", 304, 187, 137, 16) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $arr1 = saveData($arr1, $Input1) $arr1 = saveData($arr1, $Input2) $arr1 = saveData($arr1, $Input3); GUICtrlSetData($Input1, "Newer X") GUICtrlSetData($Input2, "Newer Y") GUICtrlSetData($Input3, "Newer Z") Case $Button2 $arr1 = saveData($arr1, $Input1) $arr1 = saveData($arr1, $Input2) $arr1 = saveData($arr1, $Input3); _ArrayDisplay($arr1) Exit Case $Button3 _ArrayDisplay($arr1) Exit EndSwitch WEnd EndFunc The array successfully increases in size, but when called in the groups of three it is always storing the values: 3,4, and then 5. Even if the default text is left as is