P0ZiTR0N Posted April 20, 2009 Share Posted April 20, 2009 (edited) How to refresh the TreeViewList in GUI, what reads values from ini in this code after adding new value to the file?Or another question - should it be better to do the "restart" of the progam? If yes - how?parse.ini:[LIST] X=2393922 X=2393923 X=2393924 Y=2393925 Y=2393926 Y=2411648 Z=2428317 Z=6924369 Z=9641895code of project:expandcollapse popup#include <Array.au3> #include <GUIConstants.au3> #include <GuiListView.au3> #include <ListviewConstants.au3> HotKeySet("!+{Home}", "_Stop") Global $c, $c1, $c2, $datafile, $program, $echo, $insert, $add_x, $add_y, $add_z Global $chk_x_c1, $unchk_x_c1, $chk_y_c1, $unchk_y_c1, $chk_z_c1, $unchk_z_c1, $chk_all_c1, $unchk_all_c1 $program = "Config Changer" $ini_list1 = _ArrayCreate("") $tree_list_one = _ArrayCreate("") $datafile = @ScriptDir & "\parse.ini" _gui_draw() Func _gui_draw() $win = GUICreate($program, 180, 453, 325, 115) $Group1 = GUICtrlCreateGroup("All List", 16, 40, 145, 265) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;~ array of data in listview $treeOne = GUICtrlCreateListView("Checkboxes",24, 56, 130, 240, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($treeOne, 0, $LVSCW_AUTOSIZE_USEHEADER) $arr_ini = IniReadSection($datafile, "LIST") If @error Then ;~ MsgBox(4096, "", "error") Else For $c = 1 To $arr_ini[0][0] _ArrayAdd($ini_list1, $arr_ini[$c][0] & "=" & $arr_ini[$c][1]) Next EndIf _ArrayReverse ($ini_list1) _ArrayPop($ini_list1) If $c <> 0 Then dim $tree_list_one[$c] For $c1 = 0 To $c-2 $tree_list_one[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($ini_list1), $treeOne) Next EndIf $c2 = $c1 $c = 0 ;~ begin of buttons and checkboxes GUICtrlCreateGroup("", -99, -99, 1, 1) $add_x = GUICtrlCreateButton("Add X", 40, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $add_y = GUICtrlCreateButton("Add Y", 75, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $add_z = GUICtrlCreateButton("Add Z", 110, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $insert = GUICtrlCreateButton("Process", 30, 400, 113, 41, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") If $tree_list_one[0] = 0 Then GUICtrlSetState(-1, $GUI_DISABLE) Endif $Group3 = GUICtrlCreateGroup("Select", 16, 312, 145, 89) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateGroup("", -99, -99, 1, 1) $chk_x_c1 = GUICtrlCreateButton("X +", 24, 328, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_x_c1 = GUICtrlCreateButton("X -", 88, 328, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_y_c1 = GUICtrlCreateButton("Y +", 24, 344, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_y_c1 = GUICtrlCreateButton("Y -", 88, 344, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_z_c1 = GUICtrlCreateButton("Z +", 24, 360, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_z_c1 = GUICtrlCreateButton("Z -", 88, 360, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_all_c1 = GUICtrlCreateButton("All +", 24, 376, 65, 17, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") $unchk_all_c1 = GUICtrlCreateButton("All -", 88, 376, 65, 17, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") GUISetState(@SW_SHOW) return 2 endfunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $chk_x_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_x_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_y_c1 For $c = 0 To $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Y') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_y_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Y') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_z_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_z_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_all_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X|Y|Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_all_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X|Y|Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $insert For $c=0 to $c2-1 step 1 If BitOR(GUICtrlRead($tree_list_one[$c], 1), $GUI_CHECKED) = $GUI_CHECKED Then ConsoleWrite("String " & $c & " - Checked" & @CRLF) $echo = StringTrimRight(GUICtrlRead($tree_list_one[$c]),1) $echo = StringTrimLeft($echo,StringInstr($echo,'=')) ConsoleWrite("Parsed string = "& $echo & @CRLF) Else ConsoleWrite("String " & $c & " - Unchecked" & @CRLF) EndIf Next MsgBox(0,$program,"All done",1) case $add_x $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "X=" & $num2file & "" & @LF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) case $add_y $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "Y=" & $num2file & "" & @LF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) case $add_z $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "Z=" & $num2file & "" & @LF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) Case Else EndSwitch WEnd Func _Stop() MsgBox(0, $program, "Exiting",1) Exit EndFunc Edited April 21, 2009 by P0ZiTR0N Link to comment Share on other sites More sharing options...
Valuater Posted April 20, 2009 Share Posted April 20, 2009 Hopefully this can helphttp://www.autoitscript.com/forum/index.ph...st&p=2820678) Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 21, 2009 Author Share Posted April 21, 2009 Your script is still better than nothing.. tried to rewrite with _GUICtrlListView_DeleteAllItems:expandcollapse popup#include <Array.au3> #include <GUIConstants.au3> #include <GuiListView.au3> #include <ListviewConstants.au3> HotKeySet("!+{Home}", "_Stop") Global $c, $c1, $c2, $datafile, $program, $echo, $insert, $add_x, $add_y, $add_z, $treeOne Global $chk_x_c1, $unchk_x_c1, $chk_y_c1, $unchk_y_c1, $chk_z_c1, $unchk_z_c1, $chk_all_c1, $unchk_all_c1 $program = "Config Changer" $ini_list1 = _ArrayCreate("") $tree_list_one = _ArrayCreate("") $datafile = @ScriptDir & "\parse.ini" _gui_draw() Func _gui_draw() $win = GUICreate($program, 180, 453, 325, 115) $Group1 = GUICtrlCreateGroup("All List", 16, 40, 145, 265) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;~ array of data in listview _chk_gen() ;~ begin of buttons and checkboxes GUICtrlCreateGroup("", -99, -99, 1, 1) $add_x = GUICtrlCreateButton("Add X", 40, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $add_y = GUICtrlCreateButton("Add Y", 75, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $add_z = GUICtrlCreateButton("Add Z", 110, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $insert = GUICtrlCreateButton("Process", 30, 400, 113, 41, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") If $tree_list_one[0] = 0 Then GUICtrlSetState(-1, $GUI_DISABLE) Endif $Group3 = GUICtrlCreateGroup("Select", 16, 312, 145, 89) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateGroup("", -99, -99, 1, 1) $chk_x_c1 = GUICtrlCreateButton("X +", 24, 328, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_x_c1 = GUICtrlCreateButton("X -", 88, 328, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_y_c1 = GUICtrlCreateButton("Y +", 24, 344, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_y_c1 = GUICtrlCreateButton("Y -", 88, 344, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_z_c1 = GUICtrlCreateButton("Z +", 24, 360, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_z_c1 = GUICtrlCreateButton("Z -", 88, 360, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_all_c1 = GUICtrlCreateButton("All +", 24, 376, 65, 17, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") $unchk_all_c1 = GUICtrlCreateButton("All -", 88, 376, 65, 17, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") GUISetState(@SW_SHOW) return 2 endfunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $chk_x_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_x_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_y_c1 For $c = 0 To $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Y') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_y_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Y') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_z_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_z_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_all_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X|Y|Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_all_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X|Y|Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $insert For $c=0 to $c2-1 step 1 If BitOR(GUICtrlRead($tree_list_one[$c], 1), $GUI_CHECKED) = $GUI_CHECKED Then ConsoleWrite("String " & $c & " - Checked" & @CRLF) $echo = StringTrimRight(GUICtrlRead($tree_list_one[$c]),1) $echo = StringTrimLeft($echo,StringInstr($echo,'=')) ConsoleWrite("Parsed string = "& $echo & @CRLF) Else ConsoleWrite("String " & $c & " - Unchecked" & @CRLF) EndIf Next MsgBox(0,$program,"All done",1) case $add_x $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "X=" & $num2file & "" & @LF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) _GUICtrlListView_DeleteAllItems($treeOne) _chk_gen() case $add_y $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "Y=" & $num2file & "" & @LF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) _GUICtrlListView_DeleteAllItems($treeOne) _chk_gen() case $add_z $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "Z=" & $num2file & "" & @LF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) _GUICtrlListView_DeleteAllItems($treeOne) _chk_gen() Case Else EndSwitch WEnd Func _Stop() MsgBox(0, $program, "Exiting",1) Exit EndFunc Func _chk_gen() $treeOne = GUICtrlCreateListView("Checkboxes",24, 56, 130, 240, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($treeOne, 0, $LVSCW_AUTOSIZE_USEHEADER) $arr_ini = IniReadSection($datafile, "LIST") If @error Then ;~ MsgBox(4096, "", "error") Else For $c = 1 To $arr_ini[0][0] _ArrayAdd($ini_list1, $arr_ini[$c][0] & "=" & $arr_ini[$c][1]) Next EndIf _ArrayReverse ($ini_list1) _ArrayPop($ini_list1) If $c <> 0 Then dim $tree_list_one[$c] For $c1 = 0 To $c-2 $tree_list_one[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($ini_list1), $treeOne) Next EndIf $c2 = $c1 $c = 0 EndFuncStill the same trouble - blank checkbox-list without text after pressing [add x/y/z]Any ideas where is the mistake? Link to comment Share on other sites More sharing options...
Spiff59 Posted April 21, 2009 Share Posted April 21, 2009 I chopped it up a little... Think I'd have to dig into the array.udf figure out how ini_list1 is getting trashed. I think you might be better off not using all the UDF calls and manipulating your arrays the old fashioned way. The dim at line 166, and removal of the _ArrayAdd at 168 seems to have you farther along... expandcollapse popup#include <Array.au3> #include <GUIConstants.au3> #include <GuiListView.au3> #include <ListviewConstants.au3> HotKeySet("!+{Home}", "_Stop") Global $c, $c1, $c2, $datafile, $program, $echo, $insert, $add_x, $add_y, $add_z, $treeOne Global $chk_x_c1, $unchk_x_c1, $chk_y_c1, $unchk_y_c1, $chk_z_c1, $unchk_z_c1, $chk_all_c1, $unchk_all_c1 $program = "Config Changer" $ini_list1 = _ArrayCreate("") $tree_list_one = _ArrayCreate("") $datafile = @ScriptDir & "\parse.ini" $win = GUICreate($program, 180, 453, 325, 115) $Group1 = GUICtrlCreateGroup("All List", 16, 40, 145, 265) GUICtrlSetFont(-1, 8, 400, 0, "Arial") ;~ array of data in listview $treeOne = GUICtrlCreateListView("Checkboxes",24, 56, 130, 240, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetColumnWidth($treeOne, 0, $LVSCW_AUTOSIZE_USEHEADER) _chk_gen() ;~ begin of buttons and checkboxes GUICtrlCreateGroup("", -99, -99, 1, 1) $add_x = GUICtrlCreateButton("Add X", 40, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $add_y = GUICtrlCreateButton("Add Y", 75, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $add_z = GUICtrlCreateButton("Add Z", 110, 2, 35, 26, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $insert = GUICtrlCreateButton("Process", 30, 400, 113, 41, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") If $tree_list_one[0] = 0 Then GUICtrlSetState(-1, $GUI_DISABLE) Endif $Group3 = GUICtrlCreateGroup("Select", 16, 312, 145, 89) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateGroup("", -99, -99, 1, 1) $chk_x_c1 = GUICtrlCreateButton("X +", 24, 328, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_x_c1 = GUICtrlCreateButton("X -", 88, 328, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_y_c1 = GUICtrlCreateButton("Y +", 24, 344, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_y_c1 = GUICtrlCreateButton("Y -", 88, 344, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_z_c1 = GUICtrlCreateButton("Z +", 24, 360, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $unchk_z_c1 = GUICtrlCreateButton("Z -", 88, 360, 65, 17, 0) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $chk_all_c1 = GUICtrlCreateButton("All +", 24, 376, 65, 17, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") $unchk_all_c1 = GUICtrlCreateButton("All -", 88, 376, 65, 17, 0) GUICtrlSetFont(-1, 8, 600, 0, "Arial") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $chk_x_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_x_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_y_c1 For $c = 0 To $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Y') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_y_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Y') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_z_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_z_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $chk_all_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X|Y|Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_CHECKED) EndIf Next Case $unchk_all_c1 For $c=0 to $c2-1 step 1 If StringRegExp(GUICtrlRead($tree_list_one[$c]), 'X|Y|Z') Then GuiCtrlSetState($tree_list_one[$c], $GUI_UNCHECKED) EndIf Next Case $insert For $c=0 to $c2-1 step 1 If BitOR(GUICtrlRead($tree_list_one[$c], 1), $GUI_CHECKED) = $GUI_CHECKED Then ConsoleWrite("String " & $c & " - Checked" & @CRLF) $echo = StringTrimRight(GUICtrlRead($tree_list_one[$c]),1) $echo = StringTrimLeft($echo,StringInstr($echo,'=')) ConsoleWrite("Parsed string = "& $echo & @CRLF) Else ConsoleWrite("String " & $c & " - Unchecked" & @CRLF) EndIf Next MsgBox(0,$program,"All done",1) case $add_x $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "X=" & $num2file & "" & @CRLF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) _GUICtrlListView_DeleteAllItems($treeOne) _chk_gen() case $add_y $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "Y=" & $num2file & "" & @CRLF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) _GUICtrlListView_DeleteAllItems($treeOne) _chk_gen() case $add_z $file = FileOpen($datafile,1) $num2file = Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) & Random(1,9,1) $data2file = "Z=" & $num2file & "" & @CRLF FileWriteLine($file, $data2file) ConsoleWrite("added line: " & $data2file) FileClose($file) _GUICtrlListView_DeleteAllItems($treeOne) _chk_gen() Case Else EndSwitch WEnd Func _Stop() MsgBox(0, $program, "Exiting",1) Exit EndFunc Func _chk_gen() $arr_ini = IniReadSection($datafile, "LIST") Dim $ini_list1[$arr_ini[0][0] + 1] For $c = 1 To $arr_ini[0][0] $ini_list1[$c] = $arr_ini[$c][0] & "=" & $arr_ini[$c][1] Next _ArrayReverse ($ini_list1) _ArrayPop($ini_list1) If $c <> 0 Then dim $tree_list_one[$c] For $c1 = 0 To $c-2 $tree_list_one[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($ini_list1), $treeOne) Next EndIf $c2 = $c1 $c = 0 EndFunc Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 21, 2009 Author Share Posted April 21, 2009 Funny.. great thanx, I'm happy ... topic solved Link to comment Share on other sites More sharing options...
Spiff59 Posted April 21, 2009 Share Posted April 21, 2009 (edited) Looking at array.udf, it appears that calling _ArrayPop when the array has only one element converts the array variable to an empty string variable. Rather than emptying the last element: $array[0] = "" It instead zaps the array entirely: $array = "" I'm not sure that's very useful behavior, or even the function's intended behavior. I wouldn't bother using arrayadd, arraypop, etc. One or two lines of code can do what they do and you'll know what result you're going to get. Edit: It's not very logical that the following would cause an error: #include<array.au3> $array[1] = "xyzzy" _ArrayPop($array) _ArrayAdd($array, "foobar") I'd submit a bug trac on it except half-way through writing it I'd switch to saying how I really feel: That all 3 of those functions ought to be deleted from the UDF. That 20-line functions that replace one or two lines of code are worthless. Am getting grumpy, must be bedtime. Edited April 21, 2009 by Spiff59 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