Sign in to follow this  
Followers 0

Bug in Array Display over 3999 items

31 posts in this topic

Posted

Hi,

Bug in Array Display over 3999 items; presumably so in any ListView GUI?; only in beta (10 anyway), not production.

; arraydispBug2.au3
#include<array.au3>
local $Files [4001]
for $i=0 to 4000
	$Files [$i]=$i
Next
_ArrayDisplay($Files)
Look at item 3999;

Best, Randall

Share this post


Link to post
Share on other sites



Posted (edited)

Remarks

You can not use this function to insert subitems. Use _GUICtrlListView_SetItemText to insert subitems.

Edited by -Ultima-

Share this post


Link to post
Share on other sites

Posted

Hi,

True,

But it still needs to be fixed by whomever changed it to new UDF type; ? garyfrost?

best, randall

Share this post


Link to post
Share on other sites

Posted

Why does it only draw 1/2 of the last term?

Share this post


Link to post
Share on other sites

Posted

Hi,

True,

But it still needs to be fixed by whomever changed it to new UDF type; ? garyfrost?

best, randall

Now that we have the callback feature, I'm going to look into replacing the simplesort with a callback, then won't need the arraysort.

If your going to keep using the listview functions in the _ArrayDisplay you'll need to stringsplit and set the subitems

Share this post


Link to post
Share on other sites

Posted

Now that we have the callback feature, I'm going to look into replacing the simplesort with a callback, then won't need the arraysort.

If your going to keep using the listview functions in the _ArrayDisplay you'll need to stringsplit and set the subitems

Hi,

I have no idea what the dllcallback does! Nor why it is relevant to _ArrayDisplay?....

Oh well, i'll learn 1 day..

Meantime, I have proposed a fix to _ArrayDisplay ; "_ArrayDebugDisplay"

_ArrayDebugDisplay

and maybe you could add this to yours?

Func _GUICtrlListView_AddItemRow($hListView, $m, $avArrayText, $Sep)
    Local $arItems = StringSplit($avArrayText, $Sep)
    _GUICtrlListView_AddItem ($hListView, $arItems[1], $m)
    If UBound($arItems) < 2 Then Return 1
    For $k = 2 To UBound($arItems) - 1
        _GUICtrlListView_AddSubItem ($hListView, $m, $arItems[$k], $k-1)
    Next
    Return 1
EndFunc   ;==>_GUICtrlListView_AddItems
Best, Randall

Share this post


Link to post
Share on other sites

Posted (edited)

O.o

;===============================================================================
;
; Function Name:   _ArrayDisplay()
; Description:     Displays given 1D or 2D array array in a listview.
;
; Parameter(s):    $avArray    - Array to display
;                  $sTitle     - [optional] Title to use for window
;                  $iItemLimit - [optional] Maximum number of listview items (rows) to show
;                  $iTranspose - [optional] If set differently than default, will transpose the array if 2D
;                  $sSeparator - [optional] Change Opt("GUIDataSeparatorChar") on-the-fly
;                  $sReplace   - [optional] String to replace any occurrence of $sSeparators with in each array elements
;
; Return Value(s): Success - Returns 1
;                  Failure - Returns 0 and sets @error
;                  @Error  - 1 = $avArray is not an array
;                            2 = $avArray has too many dimensions (only up to 2D supported)
;
; Author(s):       Ultima
;
;===============================================================================
Func _ArrayDisplay(Const ByRef $avArray, $sTitle = "Array: ListView Display", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "|", $sReplace = "~")
	If Not IsArray($avArray) Then Return SetError(1, 0, 0)

	; Dimension checking
	Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1), $iSubItems = UBound($avArray, 2)
	If $iDimension > 2 Then Return SetError(2, 0, 0)

	; Hard limits
	Local $iColLimit = 250, $iLVIAddUDFThreshold = 4000, $iWidth = 640, $iHeight = 480
	If $iItemLimit = 1 Then $iItemLimit = $iLVIAddUDFThreshold

	; Declare/define variables
	Local $i, $j, $avArrayText, $aiCurItem, $sHeader = "Row"
	Local $iOnEventMode = Opt("GUIOnEventMode", 0), $sDataSeparatorChar = Opt("GUIDataSeparatorChar", $sSeparator)

	; Swap dimensions if transposing and array is 2D
	If $iTranspose And $iDimension > 1 Then
		Local $tmp = $iUBound
		$iUBound = $iSubItems
		$iSubItems = $tmp
	EndIf

	; Set limits for dimensions
	If Not $iUBound Then $iUBound = 1
	If Not $iSubItems Then $iSubItems = 1
	If $iSubItems > $iColLimit Then $iSubItems = $iColLimit
	If $iItemLimit < 1 Then $iItemLimit = $iUBound
	If $iUBound > $iItemLimit Then $iUBound = $iItemLimit
	If $iLVIAddUDFThreshold > $iUBound - 1 Then $iLVIAddUDFThreshold = $iUBound - 1

	; Convert array into text for listview
	Dim $avArrayText[$iUBound]
	If $iDimension = 1 Then
		For $i = 0 To $iUBound - 1
			$avArrayText[$i] = "[" & $i & "]" & $sSeparator & StringReplace($avArray[$i], $sSeparator, $sReplace, 0, 1)
		Next
	ElseIf $iTranspose Then
		For $i = 0 To $iUBound - 1
			$avArrayText[$i] = "[" & $i & "]"
			For $j = 0 To $iSubItems - 1
				$avArrayText[$i] &= $sSeparator & StringReplace($avArray[$j][$i], $sSeparator, $sReplace, 0, 1)
			Next
		Next
	Else
		For $i = 0 To $iUBound - 1
			$avArrayText[$i] = "[" & $i & "]"
			For $j = 0 To $iSubItems - 1
				$avArrayText[$i] &= $sSeparator & StringReplace($avArray[$i][$j], $sSeparator, $sReplace, 0, 1)
			Next
		Next
	EndIf

	; Set header up
	For $i = 0 To $iSubItems - 1
		$sHeader &= $sSeparator & "Col " & $i
	Next

	; Set interface up
	Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, Default, Default, $WS_SIZEBOX + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)
	Local $aiGUISize = WinGetClientSize($hGUI)
	Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1]-26, $LVS_SHOWSELALWAYS, $LVS_EX_FULLROWSELECT + $WS_EX_CLIENTEDGE)
	Local $hCopy = GUICtrlCreateButton("Copy Selected", 3, $aiGUISize[1]-23, $aiGUISize[0]-6, 20) 

	GUICtrlSetResizing($hListView, $GUI_DOCKBORDERS)
	GUICtrlSetResizing($hCopy, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
	GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)

	; Fill listview
	For $i = 0 To $iLVIAddUDFThreshold
		GUICtrlCreateListViewItem($avArrayText[$i], $hListView)
	Next
    For $i = ($iLVIAddUDFThreshold + 1) To ($iUBound - 1)
        _GUICtrlListView_InsertItem($hListView, "")
        _GUICtrlListView_SetItemText($hListView, $i, $avArrayText[$i], -1)
    Next

	; Show dialog
	GUISetState(@SW_SHOW, $hGUI)
	While 1
		Switch GUIGetMsg()
			Case $GUI_EVENT_CLOSE
				ExitLoop
			Case $hCopy
				Local $sClip = ""
				$aiCurItem = _GUICtrlListView_GetSelectedIndices($hListView, True)
				If Not $aiCurItem[0] Then
					For $i = 0 To $iUBound - 1
						$sClip &= $avArrayText[$i] & @CRLF
					Next
				Else
					For $i = 1 To UBound($aiCurItem) - 1
						$sClip &= $avArrayText[$aiCurItem[$i]] & @CRLF
					Next
				EndIf
				ClipPut($sClip)
		EndSwitch
	WEnd
	GUIDelete($hGUI)

	Opt("GUIOnEventMode", $iOnEventMode)
	Opt("GUIDataSeparatorChar", $sDataSeparatorChar)

	Return 1
EndFunc   ;==>_ArrayDisplay

		_GUICtrlListView_InsertItem($hListView, "")
		_GUICtrlListView_SetItemText($hListView, $i, $avArrayText[$i], -1)

It's as simple as doing this :P

Edit: @GaryFrost: I think you need to update the function header to note that -1 means that it'll set the text for each subitem.

Edited by -Ultima-

Share this post


Link to post
Share on other sites

Posted

		_GUICtrlListView_InsertItem($hListView, "")
		_GUICtrlListView_SetItemText($hListView, $i, $avArrayText[$i], -1)

It's as simple as doing this :P

Edit: @GaryFrost: I think you need to update the function header to note that -1 means that it'll set the text for each subitem.

thanks!

How did you know that? -It's not in the helpFile either!?

Best, randall

Share this post


Link to post
Share on other sites

Posted

@randallc, @jos

where do we put the Ultima proposal which fix the issue?

I propose to put it in debug.au3 and in the same time change the name to _DebugArrayDisplay()

Share this post


Link to post
Share on other sites

Posted (edited)

@randallc, @jos

where do we put the Ultima proposal which fix the issue?

I propose to put it in debug.au3 and in the same time change the name to _DebugArrayDisplay()

Hi,

Not sure, myself.

@Valik says the "bloat" problem is "fixed" in "3.2.11.0", so not sure where he stands now, and whether it needs be moved to "deBug.au3" or not...;

Standard Library bloat issue, Fixed 3.2.11.0

I also wanted to change "ArrayDisplay" back to msgbox which would display only column 1 of 2D array, and warn to use the other function for 2D, but he wasn't happy! - surprise.

[incidentally, my "_ArrayDebugDisplay" also fixes this current issue, but changes back more to current _ArrayDisplay" in other matters, but Ultima does not like it.. _ArrayDebugDisplay.au3

1. It also fixes the issue of too many columns not displaying.

2. It allows 1D to be transposed to read across instead of down (ie retains current capability and compatability)

3. It accepts Ultima's changes for speeding up, and numbering how many items to display; otherwise.

4. it allows naming the column headers by piping the 'Title" parameter; eg used in _ArrayDisplay3D.au3" UDFs_ArrayDisplay3Df.au3

But @Ultima not keen, as believes it increases complexity inappropriately.]

Edited by randallc

Share this post


Link to post
Share on other sites

Posted

I never said it was fixed. Another developer put the "Fixed in 3.2.11.0" tag on that, which is partially true as Gary and myself have done a few things since the last release to reduce the bloat. It's by no means fixed and likely will never be to a state I'm happy with it but some major issues were addressed. As far as I know, _ArrayDisplay() and it's bloat are still in Array.au3.

I'm fine with JP's idea of putting it in Debug.au3 and renaming it _DebugArrayDisplay(). Just post a version of the function you're happy with and that's where it will end up. That's all that's holding back this from being "Fixed in 3.2.11.0".

Share this post


Link to post
Share on other sites

Posted

I prefer all these changes to go into the newly developed array.au3 and start using that soon in the new Beta to give it time to discover any Bugs and fix these issues before the next Production release.

I don't see why we should move ArrayDisplay since that will break current scripts and its an Array UDF. Understand its mostly used for debugging purpose but it has been in Array since day one.

Jos

Share this post


Link to post
Share on other sites

Posted

I prefer all these changes to go into the newly developed array.au3 and start using that soon in the new Beta to give it time to discover any Bugs and fix these issues before the next Production release.

I don't see why we should move ArrayDisplay since that will break current scripts and its an Array UDF. Understand its mostly used for debugging purpose but it has been in Array since day one.

Jos

I don't see why it's such a script breaker. I have never heard of any one using it for any purpose than debugging and that's really the only thing it's any good for. I would never dream of #including that the current array.au3 file (in a final script) without removing the array display function first. The reason I won't #include array.au3 is because of that function.

Share this post


Link to post
Share on other sites

Posted (edited)

I don't see why it's such a script breaker. I have never heard of any one using it for any purpose than debugging and that's really the only thing it's any good for. I would never dream of #including that the current array.au3 file (in a final script) without removing the array display function first. The reason I won't #include array.au3 is because of that function.

There are other solutions to avoid the addition of too much extra weight to your script due to this UDF. Edited by Jos

Share this post


Link to post
Share on other sites

Posted

The move to another lib was motivated by the big inclusion due to GUIListview.au3. If we go back to a MsgBox approach it can stay here in Array.au3 without name changing.

If we want to keep the display as a listiew the suggestion was to move it in debug.au3 with or without renaming I don't really care. It was just for coherent naming.

Share this post


Link to post
Share on other sites

Posted

There are other solutions to avoid the addition of too much extra weight to your script due to this UDF.

Those aren't solutions, they don't fix the problem, which is the bloat this function introduces. They are just work-arounds to reduce the bloat after-the-fact. JP summed up the solutions. Either this function gets trimmed down to be a MsgBox() again or it goes to a different file.

Share this post


Link to post
Share on other sites

Posted

My point is that the function really is designed for debug purposes and it would be better (IMHO) to use

#include <Array.au3>

#include <Debug.au3>

for testing a script and then remove the debug.au3 line when you're finished with debugging.

When writing a script that is just to be used for debugging other scripts then, assuming there will be more debug functions, you would probably want to #include <debug.au3> and not necessarily array.au3 anyway. What if your script is not using any of the functions in array.au3 but you do have an array that you want to check?

As it is I already have _ArrayDisplay() in a debug.au3 file and I #include <Arrayx.au3> instead of <array.au3>

To me this is a work-around that makes sense.

Share this post


Link to post
Share on other sites

Posted

Gary has re-written the function not to #include anything else. To me, that's an acceptable solution.

Share this post


Link to post
Share on other sites

Posted

Gary has re-written the function not to #include anything else. To me, that's an acceptable solution.

Agreed that it's a livable solution. But I will probably continue to move it to the debug.au3 file anyway. Or at least put a copy in there as __ArrayDisplay() while continuing to #include arrayx.au3 My big concern (like you) was the fact that the function previously required inclusion of GUIConstants.au3. I am aware that the GUIConstants.au3 has changed as well so it (hopefully) won't be the nightmare that it used to be.

Share this post


Link to post
Share on other sites

Posted

Agreed that it's a livable solution. But I will probably continue to move it to the debug.au3 file anyway. Or at least put a copy in there as __ArrayDisplay() while continuing to #include arrayx.au3 My big concern (like you) was the fact that the function previously required inclusion of GUIConstants.au3. I am aware that the GUIConstants.au3 has changed as well so it (hopefully) won't be the nightmare that it used to be.

Array.au3 won't include any other files.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0