Sign in to follow this  
Followers 0

_ArrayDisplay : No bug, just a wish

36 posts in this topic

Posted

HI,

I often use _ArrayDisplay to check things. I would be nice, if $sTitle was an optional parameter so that I do not think about it every time. :whistle:

So long,

Mega

Share this post


Link to post
Share on other sites



Posted

I rewrite _ArrayDisplay every time I download the new version of AutoIt. So it would be good to see it as optional.

Share this post


Link to post
Share on other sites

Posted

Yes, would save me from re-writing as well, throws me off sometimes when I post examples using it, and I have to remember to put the extra parameter, even though it's always blank. I only use it for debugging/testing anyway.

Share this post


Link to post
Share on other sites

Posted

Hi,

thanks for suppoting this request. So, now it is up to JdeB ... I guess. :-)

So long,

Mega

Share this post


Link to post
Share on other sites

Posted

Hi,

thanks for suppoting this request. So, now it is up to JdeB ... I guess. :-)

So long,

Mega

Will make the Title optional for the next release ..... :whistle:

Share this post


Link to post
Share on other sites

Posted (edited)

Will make the Title optional for the next release ..... :whistle:

JdeB whilst you on the case

A minor niggle with this command(_ArrayDisplay) is that in cases of largish array contents the messagebox

which should display the array contents doesnt always showup. The Taskbar shows the footprint, but no messagebox appears visually.

The below example code reproduces the problem on my system.

I think this command maybe needs to impose a limit on the output somehow. As others mentioned already, I also use this command for debugging purposes, and with the advent of the wonderful command _FileReadToArray() I often encounter this problem, so had to customise my copy of ArrayDisplay command to only show the first 100 elements. I appreciate this limit would not be acceptable to many, but it did make me scratch my head a while, when the array messagebox wouldn't display.

#include<Array.au3>
Global $aMyData[3000]
Global $sString = "I am an some dummy data, used as part of a string"
    For $iC = 1 To UBound($aMyData)-1
        $aMyData[$iC] = $iC & " " & $sString
    Next
_ArrayDisplay($aMyData,"Test Limit")
    ConsoleWrite(@error & @CRLF)
Exit

Regards

HardCopy

Edited by HardCopy

Share this post


Link to post
Share on other sites

Posted (edited)

Well, i notice this bug(?) also, and even if the msgbox is shown, and there many array elements (more then MsgBox can show), then you don't get all elements displayed...

So i decided to make my own version on function _ArrayDisplay() :

Func _ArrayDisplayEx(Const ByRef $avArray, $sTitle="")
    Local $sMsg = ""
    If Not IsArray($avArray) Then Return SetError(1, 0, 0)
    
    If (UBound($avArray) - 1) <= 40 Then
        For $iCounter = 0 To UBound($avArray) - 1
            $sMsg &= "[" & $iCounter & "] = " & StringStripCR($avArray[$iCounter]) & @LF
        Next
        MsgBox(4096, $sTitle, $sMsg)
    Else
        Local $Width = @DesktopWidth-5
        Local $Height = @DesktopHeight-90
        Local $Left = 20, $Top = 40, $Msg, $ArrCount = 1
        
        GUICreate($sTitle, $Width, $Height, 0, 0)
        Local $CloseButton = GUICtrlCreateButton("Close", 20, $Height-40)
        
        GUICtrlCreateTab(10, 10, $Width-20, $Height-70)
        GUICtrlCreateTabItem("Array elements #" & $ArrCount)
        
        For $iCounter = 0 To UBound($avArray) - 1
            GUICtrlCreateInput("[" & $iCounter & "] = " & StringStripCR($avArray[$iCounter]), _
                $Left, $Top, $Width-40, 15, 0x0880, 0x990)
            $Top += 28
            If $Top >= (28*20)+40 And $iCounter < UBound($avArray) - 1 Then
                $Top = 40
                $ArrCount += 1
                GUICtrlCreateTabItem("Array elements #" & $ArrCount)
            EndIf
        Next
        GUISetState()
        While 1
            $Msg = GUIGetMsg()
            If $Msg = $CloseButton Or $Msg = -3 Then ExitLoop
        WEnd
    EndIf
    Return SetError(0, 0, 1)
EndFunc   ;==>_ArrayDisplayEx

If the array include more then 40 elements, then Gui window displayed - there tabs that include 20 elements each, and every tab has unique name "Array Elements #x" (where x is the growing number in variable $ArrCount).

And also, every element text, can be copied (just try to select the text and copy it).

I hope it will be usefull :whistle: (and if developers will use it as the function to display arrays in the next releases, it will be great!).

Edited by MsCreatoR

Share this post


Link to post
Share on other sites

Posted

Hi,

If you are going to bother, it is prettier and less limited to use ListBox; but either may be error prone?

;ArrayListBox.au3
#include <GUIConstants.au3>
#include <GuiList.au3>
#include<Array.au3>
Opt('MustDeclareVars', 1)
Global $sString = "I am an some dummy data, used as part of a string"
Global $aMyData[5000], $msg, $ret, $listbox, $button
For $iC = 1 To UBound($aMyData) - 1
    $aMyData[$iC] = $iC & " " & $sString
Next
_ArrayDisplayList($aMyData, "Test Limit")
Func _ArrayDisplayList(Const ByRef $avArray, $sTitle = "")
    Local $Width = @DesktopWidth - 5, $iTimer
    Local $Height = @DesktopHeight - 90
    Local $Left = 20, $Top = 40, $msg, $ArrCount = 1
    GUICreate($sTitle, $Width, $Height, 0, 0)
    Local $CloseButton = GUICtrlCreateButton("Close", 20, $Height - 40)
    $listbox = GUICtrlCreateList("", 10, 10, $Width - 20, $Height - 70, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
    GUISetState()
    $iTimer = TimerInit()
    For $iCounter = 0 To UBound($avArray) - 1
        GUICtrlSetData($listbox, "[" & $iCounter & "] = " & StringStripCR($avArray[$iCounter]))
    Next
    ConsoleWrite("Num in 1 sec:" & Round((UBound($avArray) - 1) * 1000 / TimerDiff($iTimer)) & @LF)
    While 1
        $msg = GUIGetMsg()
        If $msg = $CloseButton Or $msg = -3 Or $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>_ArrayDisplayList

Share this post


Link to post
Share on other sites

Posted

Good idea with the list, maybe the ListView will be better?

Func _ArrayDisplayList(Const ByRef $avArray, $sTitle = "")
   If Not IsArray($avArray) Then Return SetError(1, 0, 0)
    Local $Width = @DesktopWidth - 5
    Local $Height = @DesktopHeight - 90
    Local $Left = 20, $Top = 40, $msg, $ArrCount = 1
    GUICreate($sTitle, $Width, $Height, 0, 0)
    Local $CloseButton = GUICtrlCreateButton("Close", 20, $Height - 40, 60)
    Local $CopyButton = GUICtrlCreateButton("Copy Selected", 100, $Height - 40, 80)
    Local $ListView = GUICtrlCreateListView("Element Text|Count", 10, 10, $Width - 20, $Height - 70, 0x0208+0x0004, 0x00000021)
    GUISetState()
    
    For $iCounter = 0 To UBound($avArray) - 1
        GUICtrlCreateListViewItem(StringStripCR($avArray[$iCounter]) & "|[" & $iCounter & "]", $ListView)
    Next
    GUICtrlSendMsg($ListView, 0x101E, 0, -1)
    
    While 1
        $msg = GUIGetMsg()
        If $msg = $CloseButton Or $msg = -3 Or $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $CopyButton And GUICtrlRead($ListView) <> "" Then ClipPut(GUICtrlRead(GUICtrlRead($ListView)))
    WEnd
    Return SetError(0, 0, 1)
EndFunc

Share this post


Link to post
Share on other sites

Posted

Good idea with the list, maybe the ListView will be better?

List is not limited by 4000 odd items, though...

Best, Randall

Share this post


Link to post
Share on other sites

Posted

List is not limited by 4000 odd items, though...

Best, Randall

LV is 5x as fast as tabs or List to the 4000, though; so maybe use "Insert" after 4000 only (slower);
_GUICtrlListViewInsertItem($ListView, -1, StringStripCR($avArray[$iCounter]) & "|[" & $iCounter & "]")oÝ÷ Ù«­¢+ÙÕ¹}ÉÉå¥ÍÁ±å1X¡
½¹ÍР   åIÀÌØíÙÉÉä°ÀÌØíÍQ¥Ñ±ôÅÕ½ÐìÅÕ½Ðì¤(%%9½Ð%ÍÉÉä ÀÌØíÙÉÉä¤Q¡¸IÑÕɸMÑÉÉ½È Ä°À°À¤(%1½°ÀÌØí]¥Ñ ôͭѽÁ]¥Ñ ´Ô°ÀÌØí!¥¡ÐôͭѽÁ!¥¡Ð´äÀ°ÀÌØí1ÐôÈÀ°ÀÌØíQ½ÀôÐÀ°ÀÌØíµÍ°ÀÌØíÉÉ
½Õ¹ÐôÄ°ÀÌØí¥Q¥µÈ(%U%
ÉÑ ÀÌØíÍQ¥Ñ±°ÀÌØí]¥Ñ °ÀÌØí!¥¡Ð°À°À¤(%1½°ÀÌØí
±½Í  ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí
±½ÍÅÕ½Ðì°ÈÀ°ÀÌØí!¥¡Ð´ÐÀ°ØÀ¤(%1½°ÀÌØí
½Áå  ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí
½ÁäM±ÑÅÕ½Ðì°ÄÀÀ°ÀÌØí!¥¡Ð´ÐÀ°àÀ¤(%1½°ÀÌØí1¥ÍÑY¥ÜôU%
Ñɱ
ÉÑ1¥ÍÑY¥Ü ÅÕ½Ðí±µ¹ÐQáÑñ
½Õ¹ÐÅÕ½Ðì°ÄÀ°ÄÀ°ÀÌØí]¥Ñ ´ÈÀ°ÀÌØí!¥¡Ð´ÜÀ°ÁàÀÈÀà¬ÁàÀÀÀаÁàÀÀÀÀÀÀÈĤ(%U%MÑMÑÑ ¤($ÀÌØí¥Q¥µÈôQ¥µÉ%¹¥Ð ¤(%½ÈÀÌØí¥
½Õ¹ÑÈôÀQ¼U  ½Õ¹ ÀÌØíÙÉÉ䤴Ä($%%ÀÌØí¥
½Õ¹ÑȱÐìÐÀÀÀQ¡¸($$%U%
Ñɱ
ÉÑ1¥ÍÑY¥Ý%Ñ´¡MÑÉ¥¹MÑÉ¥Á
H ÀÌØíÙÉÉålÀÌØí¥
½Õ¹ÑÉt¤µÀìÅÕ½ÐíñlÅÕ½ÐìµÀìÀÌØí¥
½Õ¹ÑȵÀìÅÕ½ÐítÅÕ½Ðì°ÀÌØí1¥ÍÑY¥Ü¤($%±Í($$%}U%
Ñɱ1¥ÍÑY¥Ý%¹ÍÉÑ%Ñ´ ÀÌØí1¥ÍÑY¥Ü°´Ä°MÑÉ¥¹MÑÉ¥Á
H ÀÌØíÙÉÉålÀÌØí¥
½Õ¹ÑÉt¤µÀìÅÕ½ÐíñlÅÕ½ÐìµÀìÀÌØí¥
½Õ¹ÑȵÀìÅÕ½ÐítÅÕ½Ðì¤($%¹%(%9áÐ(%U%
ÑɱM¹5Í ÀÌØí1¥ÍÑY¥Ü°ÁàÄÀÅ°À°´Ä¤(%
½¹Í½±]É¥Ñ ÅÕ½Ðí9Õ´¥¸ÄÍèÅÕ½ÐìµÀìI½Õ¹ ¡U  ½Õ¹ ÀÌØíÙÉÉ䤴Ĥ¨ÄÀÀÀ¼Q¥µÉ¥ ÀÌØí¥Q¥µÈ¤¤µÀì1¤(%]¡¥±Ä($$ÀÌØíµÍôU%Ñ5Í ¤($%%ÀÌØíµÍôÀÌØí
±½Í  ÕÑѽ¸=ÈÀÌØíµÍô´Ì=ÈÀÌØíµÍôÀÌØíU%}Y9Q}
1=MQ¡¸á¥Ñ1½½À(íø$%%ÀÌØíµÍôÀÌØí
½Áå  ÕÑѽ¸¹U%
ÑɱI ÀÌØí1¥ÍÑY¥Ü¤±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸
±¥ÁAÕСU%
ÑɱI¡U%
ÑɱI ÀÌØí1¥ÍÑY¥Ü¤¤¤(%]¹(%IÑÕɸMÑÉÉ½È À°À°Ä¤)¹Õ¹ìôôÐí}ÉÉå¥ÍÁ±å1X
[This has all been done before for displaying 1 or 2D arrays (see in my _GUICtrlListView UDF in signature), "ArrayTextBox2D , by someone else, or modified for fast sorting in _Array2D1D.au3]; but your smaller one might still be sensible and less overhead for simple 1D array view

Randall

[PS I don't think your copy code is working?...]

Share this post


Link to post
Share on other sites

Posted

I would like to update the current _ArrayDisplay() with some of the above mentioned ideas and at the same time allow a 2d array to be displayed.

Any good versions out there that:

1 wouldn't break current scripts

2.Uses a GUI with a List to display the array.

3.Allow 1 and 2 d arrats as input

would be helpfull ?

Thanks

Share this post


Link to post
Share on other sites

Posted

I would like to update the current _ArrayDisplay() with some of the above mentioned ideas and at the same time allow a 2d array to be displayed.

Any good versions out there that:

1 wouldn't break current scripts

2.Uses a GUI with a List to display the array.

3.Allow 1 and 2 d arrats as input

would be helpfull ?

Thanks

Hi,

Mine is too untested [may still be buggy], messily written, and complex, designed for the fast sorting as a workaround, though please feel free to have a look at it for ideas [in my sig, -Array2D1D, or in Array2D].

I can't find the original ArrayBox I found ?Danny?

Here is a link to Simulcal's; I think I tested it previously, but not recently; I'll have a look too.

ArrayBox-simulcalBest, randall

Share this post


Link to post
Share on other sites

Posted

Hi,

Mine is too untested [may still be buggy], messily written, and complex, designed for the fast sorting as a workaround, though please feel free to have a look at it for ideas [in my sig, -Array2D1D, or in Array2D].

I can't find the original ArrayBox I found ?Danny?

Here is a link to Simulcal's; I think I tested it previously, but not recently; I'll have a look too.

ArrayBox-simulcalBest, randall

Hi,

I found Blindwig's original too;

Array1Box Blindwig

I'll look at that too...

Best, randall

Share this post


Link to post
Share on other sites

Posted

I don't think your copy code is working?

It's work only if you use GuiCtrlCreateListViewItem (not with inserted items).

I never was working in that way on 2-d arrays, so don't put attention on this function if it's totaly wrong :whistle:

Func _ArrayDisplayList(Const ByRef $avArray, $sTitle = "")
   If Not IsArray($avArray) Then Return SetError(1, 0, 0)
   If UBound($avArray, 0) > 2 Then Return SetError(2, 0, 0)
    Local $Width = @DesktopWidth - 5
    Local $Height = @DesktopHeight - 90
    Local $Left = 20, $Top = 40, $msg, $ArrCount = 1
    GUICreate($sTitle, $Width, $Height, 0, 0)
    Local $CloseButton = GUICtrlCreateButton("Close", 20, $Height - 40, 60)
    Local $CopyButton = GUICtrlCreateButton("Copy Selected", 100, $Height - 40, 80)
    Local $ListView = GUICtrlCreateListView("Element Text|Count", 10, 10, $Width - 20, $Height - 70, 0x0208+0x0004, 0x00000021)
    GUISetState()
    
    If UBound($avArray, 0) = 1 Then
        For $iCounter = 0 To UBound($avArray) - 1
            GUICtrlCreateListViewItem(StringStripCR($avArray[$iCounter]) & "|[" & $iCounter & "]", $ListView)
        Next
    Else
        For $iCounter = 0 To UBound($avArray, 2) - 1
            For $jCounter = 0 To UBound($avArray) - 1
                GUICtrlCreateListViewItem(StringStripCR($avArray[$jCounter][$iCounter]) & _
                    "|[" & $jCounter & "][" & $iCounter & "]", $ListView)
            Next
        Next
    EndIf
    
    GUICtrlSendMsg($ListView, 0x101E, 0, -1)
    
    While 1
        $msg = GUIGetMsg()
        If $msg = $CloseButton Or $msg = -3 Then ExitLoop
        If $msg = $CopyButton Then ClipPut(GUICtrlRead(GUICtrlRead($ListView)))
    WEnd
EndFunc

And still, i think that using tabs will be better, it much more convinient to copy the elements and see them.

Share this post


Link to post
Share on other sites

Posted

Hi,

I found Blindwig's original too;

Array1Box Blindwig

I'll look at that too...

Best, randall

Thanks, let me know when you have something to share and do some testing. :whistle:

Share this post


Link to post
Share on other sites

Posted (edited)

Hi,

Here's an example script ("_ArrayView.au3") which includes a vbs routine for fast sort and transpose; optionally use au3 sort and transpose; or only use that by using "_ArrayViewau3.au3".

Allows copying of multiple selected lines too.

Best, randall

[EDIT 1] - there is an incorrect line in both UDF s ; so the Au3 version does not properly go beyond 4000; so I will replace them now

[ If $c < 3999 Then]

[EDIT 2] - sped up, some shrinkage

[EDIT 3] - fixed fast clipPut for transposed arrays in vbs module

[EDIT 4] - fixed properly!?

[EDIT 5] - fixed copy in au3 version!?

Edited by randallc

Share this post


Link to post
Share on other sites

Posted

Hi,

ArrayDisplay for 1 or 2 dims;

I now have a faster sort in native au3 [5x as fast as GuiListViewSort, still 5-10x slower than vbs routine [vbs is 20-50x as fast as native au3 LVsort]]; could someone please test with other arrays before I bother trying to get it to set errors and document?

Thanks, randall

Share this post


Link to post
Share on other sites

Posted

I have also received this version a while ago from Smoke_N..

Would like input from regulars to see whats the best approach for this UDF and opinions:

Dim $test[100][3]
for $y = 0 to 1
For $x = 0 to 99
    $test[$x][$y] = $x
Next    
Next
_ArrayDisplay($test)

;@error 2 = Dimension range exceeded
Func _ArrayDisplay($avADArray, $sADTitle = '', $iADBase = -1)
    If IsArray($avADArray) = 0 Then Return SetError(1, 0, 0)
    If UBound($avADArray, 3) Then Return SetError(2, 0, 0)
    If $iADBase = Default Or $iADBase = -1 Then $iADBase = 0
    Local $nADWidth = @DesktopWidth / 2, $nADHeight = @DesktopHeight / 5
    Local $hWndAD = GUICreate($sADTitle, $nADWidth, $nADHeight)
    Local $hADLV = GUICtrlCreateListView('Element #|Element Value', 10, 10, $nADWidth - 10, $nADHeight - 50, -1, 0x00000001)
    Local $hADOk = GUICtrlCreateButton('OK', ($nADWidth / 2) - 110, $nADHeight - 35, 100, 30, 0x0001)
    Local $hADCopy = GUICtrlCreateButton('Copy', (($nADWidth / 2) + 10), $nADHeight - 35, 100, 30)
    GUICtrlSendMsg($hADLV, 0x1000 + 30, 1, $nADWidth - 100)
    Local $iADCC = 0, $xADCC = 0
    If UBound($avADArray, 2) Then
        For $iADCC = $iADBase To UBound($avADArray, 1) - 1
            For $xADCC = 0 To UBound($avADArray, 2) - 1
                GUICtrlCreateListViewItem('[' & $iADCC & '][' & $xADCC & ']|' & $avADArray[$iADCC][$xADCC], $hADLV)
            Next
        Next
    Else
        For $iADCC = 0 To UBound($avADArray) - 1
            GUICtrlCreateListViewItem('[' & $iADCC & ']|' & $avADArray[$iADCC], $hADLV)
        Next
    EndIf
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $hADOk, -3
                ExitLoop
            Case $hADCopy
                ClipPut(GUICtrlRead(GUICtrlRead($hADLV)))
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hWndAD)
    Return SetError(0, 0, 1)
EndFunc   ;==>_ArrayDisplayEx

Share this post


Link to post
Share on other sites

Posted

Ok,

Here is a simpler script; no sorting or transposing after called; but allow >4000 items, limit width to 250; needs "GUIListView.au3" and constants as includes; errors not fully set [**** Can this include other "includes", or do you want it to be independent?; that would require "lifting" pieces from the other GUIs??]

Checks for some faulty input; inserts a line "ND" if ListView line can't be inserted.

What else need be done to "Keep it simple", but keep this flexibility and size capability?

Best, Randall

;_ArrayViewKiss.au3 0_4
#include-once
#include <GuiConstants.au3>
#include <GuiListView.au3>
#region
#endregion
Local $rows = 4, $cols = 300, $test[$rows + 1][$cols + 1]
For $x = 0 To $rows
    For $y = 0 To $cols
        $test[$x][$y] = $x
    Next
Next
_ArrayView($test, "$test - limited columns")
_ArrayView($test, "$test Transposed", 1, 1)
;=====================================================================
Func _ArrayView($ar_2DArray, $sTitle = "ListView array 1D and 2D Display", $i_ShowOver4000 = 1, $i_Transpose = 0, $GUIDataSeparatorChar = "|", $GUIDataReplace = "~")
    Local $searchlistView, $hndButton_Close, $sTempHeader = 'Row', $i_Pos, $size, $ar_ExcelValueTrans[1][1], $s_NotDoneLine, $ret
    Local $ar_TempSingle[1], $msg, $ar_ReturnSingle[1], $hndButton_Array1Box_TextSelect, $searchGUI, $ar_2dCurrent[1][1], $GUICtrlCreateListViewItem
    If Not IsArray($ar_2DArray) Then Return SetError(1, 0, 0)
    ; Create GUI and Buttons =========================================================================================
    $searchGUI = GUICreate($sTitle, 810, 623, (@DesktopWidth - 800) / 2, (@DesktopHeight - 600) / 2, $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX)
    $hndButton_Array1Box_TextSelect = GUICtrlCreateButton('&Text' & 'Selected', 10, 550, 70, 24)
    GUICtrlSetResizing($hndButton_Array1Box_TextSelect, BitOR($GUI_DockRight, $GUI_DockBottom, $GUI_DockSize))
    $hndButton_Close = GUICtrlCreateButton('&Close', 190, 550, 70, 24)
    GUICtrlSetResizing($hndButton_Close, BitOR($GUI_DockRight, $GUI_DockBottom, $GUI_DockSize))
    GUICtrlSetState($hndButton_Array1Box_TextSelect, ($GUI_DefButton))
    ; for 1D; add index column; change to 2D array==================================================================
    If UBound($ar_2DArray, 0) = 1 Then
        ReDim $ar_2dCurrent[UBound($ar_2DArray) ][1]
        For $i = 0 To UBound($ar_2DArray) - 1
            $ar_2dCurrent[$i][0] = $ar_2DArray[$i]
        Next
        $ar_2DArray = $ar_2dCurrent
    EndIf
    ; transpose if requested==================================================================
    If $i_Transpose And IsArray($ar_2DArray) And UBound($ar_2DArray, 0) = 2 Then ; transpose if requested
        ReDim $ar_ExcelValueTrans[UBound($ar_2DArray, 2) ][UBound($ar_2DArray, 1) ]
        For $j = 0 To UBound($ar_2DArray, 2) - 1
            For $numb = 0 To UBound($ar_2DArray, 1) - 1
                If $numb > 250 Then ExitLoop  ; limit cols to about 250 as limitation  of GUICreatelistView?
                $ar_ExcelValueTrans[$j][$numb] = $ar_2DArray[$numb][$j]
            Next
        Next
        $ar_2DArray = $ar_ExcelValueTrans
    EndIf
    ;Replace any array items containing the LV separator character =============================================
    Opt("GUIDataSeparatorChar", $GUIDataSeparatorChar) ;"|" is the default
    For $x = 0 To UBound($ar_2DArray) - 1 Step 1
        For $y = 0 To UBound($ar_2DArray, 2) - 1 Step 1
            $ar_2DArray[$x][$y] = StringReplace($ar_2DArray[$x][$y], $GUIDataSeparatorChar, $GUIDataReplace)
        Next
    Next
    ;; make LV header==================================================================
    For $i = 1 To UBound($ar_2DArray, 2)
        $sTempHeader &= $GUIDataSeparatorChar & 'Col ' & $i - 1
    Next
    StringReplace($sTempHeader, $GUIDataSeparatorChar, "<")
    If @extended > 252 Then
        $i_Pos = StringInStr($sTempHeader, $GUIDataSeparatorChar, 0, 252)
        $sTempHeader = StringLeft($sTempHeader, $i_Pos - 1)
    EndIf
    $s_NotDoneLine = StringReplace($sTempHeader, "Col", "ND")
    ;change 2D array to Array LV formatted rows==================================================================
    If UBound($ar_2DArray, 0) = 2 Then
        ReDim $ar_TempSingle[UBound($ar_2DArray) ]
        For $i = 0 To UBound($ar_2DArray) - 1
            $ar_TempSingle[$i] = "[" & $i & "]"
            For $c = 0 To UBound($ar_2DArray, 2) - 1 ;0 is base
                If $c < 251 Then
                    $ar_TempSingle[$i] &= $GUIDataSeparatorChar & $ar_2DArray[$i][$c]
                Else
                    ExitLoop;$c = UBound($ar_2DArray, 2) - 1
                EndIf
            Next
            $ar_TempSingle[$i] = StringMid($ar_TempSingle[$i], 1, StringLen($ar_TempSingle) - 1)
        Next
    Else
        $ar_TempSingle = $ar_2DArray
    EndIf
    ;Create Listview==================================================================
    $size = WinGetClientSize($sTitle)
    GUICtrlDelete($searchlistView)
    $searchlistView = GUICtrlCreateListView($sTempHeader, 0, 16, $size[0] - 10, $size[1] - 90, BitOR($LVS_SHOWSELALWAYS, $LVS_EDITLABELS), BitOR($LVS_EX_GRIDLINES, $LVS_EX_HEADERDRAGDROP, $LVS_EX_FULLROWSELECT, $LVS_EX_REGIONAL))
    GUICtrlSetResizing($searchlistView, BitOR($GUI_DockLeft, $GUI_DockTop, $GUI_DockRight, $GUI_DockBottom))
    For $c = 0 To UBound($ar_TempSingle) - 1
        If ($c < 3999) Or $i_ShowOver4000 Then
            If $c < 3999 Then
                $GUICtrlCreateListViewItem = GUICtrlCreateListViewItem($ar_TempSingle[$c], $searchlistView)
                If Not $GUICtrlCreateListViewItem Then GUICtrlCreateListViewItem($s_NotDoneLine, $searchlistView)
            Else
                $ret = _GUICtrlListViewInsertItem($searchlistView, -1, $ar_TempSingle[$c])
                If ($ret = $LV_ERR) Then _GUICtrlListViewInsertItem($searchlistView, -1, $s_NotDoneLine)
            EndIf
        ElseIf ($c >= 3999) Then
            ExitLoop
        EndIf
    Next
    _GUICtrlListViewSetColumnWidth($searchlistView, 2, $LVSCW_AUTOSIZE)
    If UBound($ar_2DArray, 2) = 1 Then _GUICtrlListViewSetColumnWidth($searchlistView, 1, $LVSCW_AUTOSIZE)
    GUISetState()
    Do ; LOOP
        $msg = GUIGetMsg(1)
        Select
            ;Copy all to clipboard(default); or multiple selected rows===============================================================)
            Case $msg[0] = $hndButton_Array1Box_TextSelect
                Local $a_indices[1], $s_CopyLines = ""
                If _GUICtrlListViewGetItemCount($searchlistView) Then $a_indices = _GUICtrlListViewGetSelectedIndices($searchlistView, 1)
                If (IsArray($a_indices)) Then
                    ClipPut("")
                    For $i = 1 To $a_indices[0]
                        $s_CopyLines &= $ar_TempSingle[ $a_indices[$i]] & @LF
                    Next
                Else
                    For $i = 1 To UBound($ar_TempSingle) - 1
                        $s_CopyLines &= $ar_TempSingle[$i] & @LF
                    Next
                EndIf
                ClipPut($s_CopyLines)
        EndSelect
    Until $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $hndButton_Close
    GUIDelete($searchGUI)
    Return SetError(0, 0, 1)
EndFunc   ;==>_ArrayView

Share this post


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