Jump to content

Need help with debugging script [solved]


P0ZiTR0N
 Share

Recommended Posts

Here is the code

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Global $i_list, $num, $c1, $c, $tree_list
$i_list = _ArrayCreate("")
$tree_list = _ArrayCreate("")
; GUI begin
$Form = GUICreate("Chekbox checker", 231, 271, 282, 140)
$Tree = GUICtrlCreateListView("Items", 8, 8, 129, 240, -1, $LVS_EX_CHECKBOXES)
_GUICtrlListView_SetColumnWidth($Tree, 0, $LVSCW_AUTOSIZE_USEHEADER)
_ArrayAdd($i_list, "text1")
_ArrayAdd($i_list, "text2")
_ArrayAdd($i_list, "text3")
_ArrayAdd($i_list, "text4")
; reversing, deleting last row with null data
_ArrayReverse($i_list)
_ArrayPop($i_list)

$c=UBound($i_list) ; size of array dimensions $i_list
dim $tree_list[$c] ; declaring $tree_list
For $c1 = 0 To $c-1
    $tree_list[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($i_list), $Tree); moving rows from $ip_list to $tree_list with creating checkboxes
    
Next
_ArrayDisplay($tree_list,"")
$Start = GUICtrlCreateButton("Start", 144, 8, 81, 25, 0)
$Exit = GUICtrlCreateButton("Exit", 144, 40, 81, 25, 0)
GUISetState(@SW_SHOW)
; Gui end

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
    For $c=0 to $c1-1 step 1
            if BitOR(GUICtrlRead($tree_list[$c], 1), $GUI_CHECKED) = $GUI_CHECKED Then ;checking state of $tree_list
            ConsoleWrite("Number " & $c & " - Checked. Item data - " & $tree_list[$c] & "" & @CRLF)
            endif
Next            
        Case $Exit
            Exit
    EndSwitch
WEnd
This is the rows in $tree_list now

post-48437-12605170489168_thumb.jpg

This is the rows what I want to put in $tree_list

post-48437-12605170543409_thumb.jpg

GUI checkbox checking is working normal now. And console writes real checked rows, but the data in array is false,- just numbers. Where could be mistake?

Edited by P0ZiTR0N
Link to comment
Share on other sites

Hi,

$tree_list[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($i_list), $Tree); moving rows from $ip_list to $tree_list with creating checkboxes

This is not moving the rows from $ip_list to $tree_list. You fill the array with the return value of GUICtrlCreateListViewItem, and this is the id of the control (see helpfile). Also The &= should be replaced by =

Return Value

Success: Returns the identifier (controlID) of the new control.

Failure: Returns 0.

You may code like this:

For $c1 = 0 To $c-1
    If GUICtrlCreateListViewItem($i_list [UBound ($i_list) - 1)], $Tree) Then ; moving rows from $ip_list to $tree_list with creating checkboxes
        $tree_list[$c1] = _ArrayPop($i_list)
    EndIf
Next

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Hi,

$tree_list[$c1] &= GUICtrlCreateListViewItem(_ArrayPop($i_list), $Tree); moving rows from $ip_list to $tree_list with creating checkboxes

This is not moving the rows from $ip_list to $tree_list. You fill the array with the return value of GUICtrlCreateListViewItem, and this is the id of the control (see helpfile). Also The &= should be replaced by =

I know this.. this is just a comment.

Your code works fine. But it breaks checkboxes checking. Here is the result of checking non-selected cb ;)

Number 0 - Checked. Item data - text1

Number 1 - Checked. Item data - text2

Number 2 - Checked. Item data - text3

Number 3 - Checked. Item data - text4

Anyway thanx
Link to comment
Share on other sites

Hi,

try version with a 2 d array:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Global $i_list, $num, $c1, $c, $tree_list
$i_list = _ArrayCreate("")
$tree_list = _ArrayCreate("")
; GUI begin
$Form = GUICreate("Chekbox checker", 231, 271, 282, 140)
$Tree = GUICtrlCreateListView("Items", 8, 8, 129, 240, -1, $LVS_EX_CHECKBOXES)
_GUICtrlListView_SetColumnWidth($Tree, 0, $LVSCW_AUTOSIZE_USEHEADER)
_ArrayAdd($i_list, "text1")
_ArrayAdd($i_list, "text2")
_ArrayAdd($i_list, "text3")
_ArrayAdd($i_list, "text4")
; reversing, deleting last row with null data
_ArrayReverse($i_list)
_ArrayPop($i_list)

$c=UBound($i_list) ; size of array dimensions $i_list
dim $tree_list[$c] [2] ; declaring $tree_list 

For $c1 = 0 To $c-1
    $tree_list [$c1] [1] = GUICtrlCreateListViewItem($i_list [UBound ($i_list) - 1], $Tree) ; moving rows from $ip_list to $tree_list with creating checkboxes
    $tree_list[$c1] [0] = _ArrayPop($i_list)
Next

_ArrayDisplay($tree_list,"")
$Start = GUICtrlCreateButton("Start", 144, 8, 81, 25, 0)
$Exit = GUICtrlCreateButton("Exit", 144, 40, 81, 25, 0)
GUISetState(@SW_SHOW)
; Gui end

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
    For $c=0 to $c1-1 step 1
            if BitOR(GUICtrlRead($tree_list[$c] [1], 1), $GUI_CHECKED) = $GUI_CHECKED Then ;checking state of $tree_list
            ConsoleWrite("Number " & $c & " - Checked. Item data - " & $tree_list[$c] [0] & "" & @CRLF)
            endif
Next            
        Case $Exit
            Exit
    EndSwitch
WEnd

;-))

Stefan

You may also change

ConsoleWrite("Number " & $c & " - Checked. Item data - " & $tree_list[$c] [0] & "" & @CRLF)

to

ConsoleWrite("ControlID " & $tree_list[$c] [1] & " - Checked. Item data - " & $tree_list[$c] [0] & "" & @CRLF)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...