koushik Posted June 25, 2008 Share Posted June 25, 2008 The following code returns an array of elements from a given SyslistView contorl handle. This code works fine when called the first time. But does not work properly when called the second time. The first array is getting deleted. What is the right way to return the array? CODEFunc getSyslistView ($listhandle, $column) $total = _GUICtrlListView_GetItemCount ($listhandle) Local $ar[1] ;MsgBox (0,"Total", $total); For $itemcounter = 0 to $total -1 $log = _GUICtrlListView_GetItemText($listHandle, $itemcounter,$column) _ArrayAdd($ar, $log) Next ;MsgBox (0,"Log", $log) if (_ArrayMaxIndex($ar) <> 0) Then _ArrayDelete ($ar,0) EndIf ;_ArrayDisplay($ar) return $ar EndFunc Thanks for the help guys. The forums rock! Cheers Koushik Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 25, 2008 Share Posted June 25, 2008 The following code returns an array of elements from a given SyslistView contorl handle. This code works fine when called the first time. But does not work properly when called the second time. The first array is getting deleted. What is the right way to return the array? CODEFunc getSyslistView ($listhandle, $column) $total = _GUICtrlListView_GetItemCount ($listhandle) Local $ar[1] ;MsgBox (0,"Total", $total); For $itemcounter = 0 to $total -1 $log = _GUICtrlListView_GetItemText($listHandle, $itemcounter,$column) _ArrayAdd($ar, $log) Next ;MsgBox (0,"Log", $log) if (_ArrayMaxIndex($ar) <> 0) Then _ArrayDelete ($ar,0) EndIf ;_ArrayDisplay($ar) return $ar EndFunc Thanks for the help guys. The forums rock! Cheers Koushik The _ArrayAdd() and _ArrayMaxIndex() stuff is very awkward. Try this: Func getSyslistView($listhandle, $column) $total = _GUICtrlListView_GetItemCount($listhandle) If $total > 0 Then Local $ar[$total - 1] For $i = 0 To $total - 1 $ar[$i] = _GUICtrlListView_GetItemText($listhandle, $i, $column) Next Return $ar Else Return SetError(1, 0, 0) EndIf EndFunc ;==>getSyslistView Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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