Jump to content

Recommended Posts

  • Moderators
Posted (edited)

Deadline of 1800 UTC 28 Nov 13 for any further comments and suggestions

Hi,

I mentioned in this thread that i was writing a new version of _ArrayDisplay - and here it is in Beta form. Changes as far as the user is concerned are:

- 1. Script-breaking The $sReplace parameter has disappeared - see below for why it is no longer necessary

- 2. The UDF changes the existing AutoIt data separator character to ChrW(0xF123) to create the ListView and then restores the existing separator on exit. If the user wants to copy data from the dialog, the separator character specified in the calling line is inserted in place of the UniCode one - as a default this is the existing character. In this case it is entirely up to the user to specify a different separator if the existing one is already included within the array.

- 3. The ListView columns now expand to fit the widest item within them - the overall dialog has min/max widths to keep it visible and on screen. There is however a maximum column width limit to prevent a single column taking over the entire dialog - this can be reset by the user if needed. However, this limit is only enforced if the dialog woudl otherwise become wider than the screen. There is also a minimum width to ensure the default headers display correctly.

- 4. Similarly, the dialog will adjust vertically to fit the number of rows - with max/min heights to keep things visible and on screen.

- 5. Script-breaking If an error occurs because the UDF was not passed a 1D/2D array, a MsgBox will appear announce this rather than just returning an error and continuing the script as before. So the user does not need to add error checking code in their script as the UDF does this for them. This was added as the general opinion seemed to be that the function is basically intended for debugging and so it is useful to know that the array that was expected has not been created. The MsgBox offers a choice of exiting the script or of continuing - in which case it returns the same specific @error value as before.

- 6. Script-breaking The $iArrayLimit parameter has been replaced with $sArrayRange which sets the contiguous rows/columns to display:

"7"        - Show rows 0-7 with all columns
"7:"       - Show rows 5-end with all columns
"|7"       - Show all rows with columns 0-7
"|7:"       - Show all rows with columns 7-end
"7|7"      - Show rows 0-7 with columns 0-7
"5:7"      - Show rows 5-7 with all columns
"|5:7"     - Show all rows with columns 5-7
"7|5:7"    - Show rows 0-7 with columns 5-7
"5:7|7"    - Show rows 5-7 with columns 0-7
"5:7|5:7"  - Show rows 5-7 with columns 5-7
.

- 7. Script-breaking The $iTranspose parameter has been replaced by $iFlags. Setting this parameter to 1 will transpose the array as before - but adding either 2 or 4 to the parameter will right or centre align the ListView columns.

- 8. The ListView will displaya max of 64k lines (a Windows limitation) and 250 columns (arbitrarily set to keep the overall size reasonable). If the user tries to display over these limits a MsgBox announces that the array display has been truncated. Note that adjusting the array range displayed allows larger arrays to be displayed in sections.

- 9. The buttons at the bottom of the dialog have been increased in number:

- a. Copy Data & Hdr/Row - this copies the array (or the selected rows) to the clipboard adding full header and row identification.

- b. Copy Data Only - this copies the array (or the selected rows) to the clipboard with no header or row identification.

- c. Run User Function - run a user-defined function if its name was passed when calling _ArrayDisplay - the idea behind this is to allow the user to log, save or print the current state of the array. To this end, the full array and another array holding the selected rows are passed to this function which is entirely separate from the UDF and must be created and coded by the user to accept these parameters. The button is disabled if no function is specified.

- d. Exit script - this exits the script immediately, just as can be the case with the error MsgBoxes. Given the debugging nature of the function, this could be useful if the array content is not as expected.

- 10. If the user specifies a colour in the relevant parameter then the ListView will be displayed with alternate row colouring - no colour specifed means all rows are the same colour.

- 11. If custom headers are uded they will be applied to as many columns as possible after which the standard default headers will be inserted.

I should also mention that the new code runs in about half the time of the existing version, which is a major advantage for large arrays. Try increasing the test array size to [2000][100] to make it more obvious.

Here is the new UDF for you to play with: <snip>

Comments and (reasonable) further proposals are welcome - so over to you. :)

M23

Edit: 1311281000UTC - new code added. Read the thread to follow the discussion if you wish - but all the salient info is in the above post :)

And here is the proposed help file page for the new function:

###User Defined Function###
_ArrayDisplay

###Description###
Displays a 1D or 2D array array in a ListView

###Syntax###
#include <Array.au3>
_ArrayDisplay ( Const ByRef $avArray [, $sTitle = "ArrayDisplay" [, $sArrayRange = "" [, $iFlags = 0 [, $sUser_Separator = Default [, $sHeader = Default [, $iMax_ColWidth = Default [, $iAlt_Color = Default [, $sUser_Function = ""]]]]]]]] )


###Parameters###
@@ParamTable@@
$avArray
    Array to display
$sTitle
    [optional] Title for dialog.  Default = none. Array dimension(s) are always displayed.
$sArrayRange
    [optional] Range of rows/columns to display.  Default = display entire array (see below for limits).    
$iFlags
    [optional] Setting to 1 transposes a 2D array.  Add 2 (right) or 4 (center) to alter columns alignment. Default = 0.
$sUser_Separator
    [optional] Separator to use when copying data from dialog. Default = current separator character (usually "|").
$sHeader
    [optional] Column names in header (names separated by current separator character - usually "|"). Default see Remarks.
$iMax_Colwidth
    [optional] Max width to which a column will expand to show content.  Default = 350 pixels.
$iAlt_Color
    [optional] If set ListView colors alternate rows. Default = all rows ListView color.
$sUser_Function
    [optional] The user defined function to run. Default = none.

@@End@@

###ReturnValue###
@@ReturnTable@@
Success:    1.
Failure:    MsgBox displayed, 0 returned and @error flag set as follows:
@error: 1 - $avArray is not an array
    2 - $avArray has too many dimensions (only 1D and 2D supported)
@@End@@


###Remarks###
A MsgBox is displayed if the function is passed a non-array variable or the array has more than 2 dimensions.  This will offer the chance to exit immediately or to continue the script.

Only 65527 rows can be displayed - this is an AutoIt limitation on the total number of controls that can be displayed in a GUI.  An abitrary display limit of 250 columns has also been set.  If the user tries to display over these limits a MsgBox announces that the  display has been truncated. Note that using $iArrayRange to set the elements to be displayed allows arrays larger than the display limits to be displayed in sections.

The $sArrayRange parameter syntax is as follows:

    "7"        - Show rows 0-7 with all columns
    "7:"       - Show rows 7-end with all columns
    "|7"       - Show all rows with columns 0-7
    "|7:"      - Show all rows with columns 7-end
    "7|7"      - Show rows 0-7 with columns 0-7
    "5:7"      - Show rows 5-7 with all columns
    "|5:7"     - Show all rows with columns 5-7
    "7|5:7"    - Show rows 0-7 with columns 5-7
    "5:7|7"    - Show rows 5-7 with columns 0-7
    "5:7|5:7"  - Show rows 5-7 with columns 5-7

$sHeader items separated by the current separator character will be used for as many columns as possible.  If no, or not enough, custom items are defined then the default header of "Row|Col0" for 1D arrays or "Row|Col0|Col1|...|Col n" for 2D is substituted.

The 4 buttons at the bottom of the dialog have the following functions:

- Copy Data & Hdr/Row - copy the array or the selected row(s) to the clipboard adding full header and row identification.

- Copy Data Only - copy the array or the selected row(s) to the clipboard with no header or row identification.

- Run User Function - run the user-defined function passed in $sUser_Function.  This function is entirely separate from the UDF and must be created and coded by the user to accept the full array and another array holding the selected rows as parameters. The button is disabled if no function is specified.

- Exit script - Exit the script immediately.

###Related###


###Example###
@@IncludeExample@@
Edited by Melba23
Beta code removed

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

This beta looks very, very good :thumbsup:

Only thing I noticed is that this line doesn't seem to have the desired effect:

$sHeader = "Row  " ; Blanks added to adjust column size for large number of rows

The column header is always shown as "R...". It looks like the function only takes the width of the data into account but ignores the header width when auto sizing a column.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • Moderators
Posted

water,

Thanks. I have added some code to set a minimum column width (50 pixels) to prevent this. New file in first post. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Works fine now!

Idea:

Would it be possible to pass the following parameters to the _UserFunc: Displayed Array, first selected row number, last selected row number.

So the user func could write the selected lines to a file or whatever.

Example:

;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

#include <Constants.au3> ; Only for _UserFunc

; UDF code begins here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include <Array.au3>

; Create an array to display
Global $aArray[200][100], $vVar = 0
For $i = 0 To UBound($aArray) - 1
    For $j = 0 To UBound($aArray, 2) - 1
        $aArray[$i][$j] = "Item " & StringFormat("%02i", $i) & StringFormat("%02i", $j)
    Next
Next
; And add a couple of long elements
$aArray[0][1] = "A longish element to show column expansion"
$aArray[0][2] = "A very much longer element to show that the column expansion is limited to prevent one single column taking over the entire dialog because of one extremely long element within it"

; Run the Beta to show it displays without problem
_ArrayDisplay_Beta($aArray, "New Beta code - note ability to use standard '|' separator in array elements", Default, Default, Default, Default, Default, "_UserFunc")

Func _ArrayDisplay_Beta(Const ByRef $avArray, $sTitle = Default, $iItemLimit = Default, $iTranspose = Default, $sUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $sUserFunc = Default)

    Local Const $_ARRAYCONSTANT_MB_SYSTEMMODAL = 4096
    Local Const $_ARRAYCONSTANT_MB_ICONERROR = 16
    Local Const $_ARRAYCONSTANT_MB_YESNO = 4
    Local Const $_ARRAYCONSTANT_IDYES = 6

    If (Not IsArray($avArray)) Then
        If MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
                "ArrayDisplay Error " & $sTitle, "No array variable passed to function" & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
            Exit
        Else
            Return SetError(1, 0, "")
        EndIf
    EndIf

    ; Default values
    If $sTitle = Default Then $sTitle = "Array: ListView Display"
    If $iItemLimit = Default Then $iItemLimit = -1
    If $iTranspose = Default Then $iTranspose = 0
    If $sUser_Separator = Default Then $sUser_Separator = ""
    If $sHeader = Default Then $sHeader = ""
    If $iMax_ColWidth = Default Then $iMax_ColWidth = 350
    If $sUserFunc = Default Then $sUserFunc = ""

    ; Dimension checking
    Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1
    If $iDimension > 2 Then
        If MsgBox($_ARRAYCONSTANT_MB_SYSTEMMODAL + $_ARRAYCONSTANT_MB_ICONERROR + $_ARRAYCONSTANT_MB_YESNO, _
                "ArrayDisplay Error " & $sTitle, "Larger than 2D array passed to function" & @CRLF & @CRLF & "Exit the script?") = $_ARRAYCONSTANT_IDYES Then
            Exit
        Else
            Return SetError(2, 0, "")
        EndIf
    EndIf

    ; Separator handling
    Local $sAD_Separator = ChrW(0xF123)
    Local $sCurr_Separator = Opt("GUIDataSeparatorChar", $sAD_Separator) ; Set separator to use in this UDF and store existing one
    If $sUser_Separator = "" Then $sUser_Separator = $sCurr_Separator

    ; Declare variables
    Local $vTmp, $iColLimit = 250

    ; Swap dimensions if transposing
    If $iSubMax < 0 Then $iSubMax = 0
    If $iTranspose Then
        $vTmp = $iUBound
        $iUBound = $iSubMax
        $iSubMax = $vTmp
    EndIf

    ; Set limits for dimensions
    If $iSubMax > $iColLimit Then $iSubMax = $iColLimit
    If $iItemLimit < 1 Then $iItemLimit = $iUBound
    If $iUBound > $iItemLimit Then $iUBound = $iItemLimit

    ; Create header
    If $sHeader = "" Then
        $sHeader = "Row"
        For $i = 0 To $iSubMax
            $sHeader &= $sAD_Separator & "Col " & $i
        Next
    EndIf

    ; Convert array into ListViewItem compatible lines
    Local $avArrayText[$iUBound + 1]
    For $i = 0 To $iUBound
        $avArrayText[$i] = "[" & $i & "]"
        For $j = 0 To $iSubMax
            ; Get current item
            If $iDimension = 1 Then
                If $iTranspose Then
                    $vTmp = $avArray[$j]
                Else
                    $vTmp = $avArray[$i]
                EndIf
            Else
                If $iTranspose Then
                    $vTmp = $avArray[$j][$i]
                Else
                    $vTmp = $avArray[$i][$j]
                EndIf
            EndIf
            $avArrayText[$i] &= $sAD_Separator & $vTmp
        Next
    Next

    ; GUI Constants
    Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 102
    Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 64
    Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 512
    Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 2
    Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 4
    Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3
    Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29)
    Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH = (0x1000 + 30)
    Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4)
    Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44)
    Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54)
    Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20
    Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1
    Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8
    Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200
    Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000
    Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000
    Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000
    Local Const $_ARRAYCONSTANT_WM_SETREDRAW = 11
    Local Const $_ARRAYCONSTANT_LVSCW_AUTOSIZE = -1

    ; Create GUI
    Local $iOrgWidth = 600, $iHeight = 480
    Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX))
    Local $aiGUISize = WinGetClientSize($hGUI)
    Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 46, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS)
    Local $cCopy_ID = GUICtrlCreateButton("Copy Data && Hdr/Row", 5, $aiGUISize[1] - 43, ($aiGUISize[0] / 2) - 10, 20)
    Local $cCopy_Data = GUICtrlCreateButton("Copy Data Only", ($aiGUISize[0] / 2) + 5, $aiGUISize[1] - 43, ($aiGUISize[0] / 2) - 10, 20)
    Local $cUser_Func = GUICtrlCreateButton("Run User Function", 5, $aiGUISize[1] - 23, ($aiGUISize[0] / 2) - 10, 20)
    Local $cExit_Script = GUICtrlCreateButton("Exit Script", ($aiGUISize[0] / 2) + 5, $aiGUISize[1] - 23, ($aiGUISize[0] / 2) - 10, 20)
    GUICtrlSetResizing($hListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS)
    GUICtrlSetResizing($cCopy_ID, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
    GUICtrlSetResizing($cCopy_Data, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
    GUICtrlSetResizing($cUser_Func, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
    GUICtrlSetResizing($cExit_Script, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE)
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_WM_SETREDRAW, 0, 0)

    ; Fill listview
    For $i = 0 To $iUBound
        GUICtrlCreateListViewItem($avArrayText[$i], $hListView)
    Next
    GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_WM_SETREDRAW, 1, 0)

    ; Adjust dialog width
    Local $iWidth = 0, $iColWidth, $iMin_ColWidth = 50
    For $i = 0 To $iSubMax + 1
        GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE)
        $iColWidth = GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0)
        ; Check for max/min width limits
        If $iColWidth > $iMax_ColWidth Then
            GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMax_ColWidth)
            $iWidth += $iMax_ColWidth
        ElseIf $iColWidth < $iMin_ColWidth Then
            GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth)
            $iWidth += $iMin_ColWidth
        Else
            $iWidth += $iColWidth
        EndIf
    Next
    ; Set min/max size
    If $iWidth < 250 Then $iWidth = 230
    If $iWidth > @DesktopWidth Then $iWidth = @DesktopWidth - 120
    ; Allow for borders
    $iWidth += 20

    ; Display and resize dialog
    GUISetState(@SW_HIDE, $hGUI)
    WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, Default, $iWidth)
    GUISetState(@SW_SHOW, $hGUI)

    Local $iOnEventMode = Opt("GUIOnEventMode", 0), $iMsg, $sClip

    While 1

        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE
                ExitLoop
            Case $cCopy_ID, $cCopy_Data
                $sClip = ""
                ; Get selected indices
                Local $aiCurItems[1] = [0]
                For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
                    If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
                        $aiCurItems[0] += 1
                        ReDim $aiCurItems[$aiCurItems[0] + 1]
                        $aiCurItems[$aiCurItems[0]] = $i
                    EndIf
                Next
                ; Generate clipboard text
                If Not $aiCurItems[0] Then
                    For $sItem In $avArrayText
                        If $iMsg = $cCopy_Data Then
                            ; Remove row ID
                            $sItem = StringRegExpReplace($sItem, "^\[\d+\]\|(.*)$", "$1")
                        EndIf
                        $sClip &= $sItem & @CRLF
                    Next
                Else
                    If $iMsg = $cCopy_ID Then
                        ; Add hdr line
                        $sClip = $sHeader & @CRLF
                    EndIf
                    For $i = 1 To UBound($aiCurItems) - 1
                        $sItem = $avArrayText[$aiCurItems[$i]]
                        If $iMsg = $cCopy_Data Then
                            ; Remove row ID
                            $sItem = StringRegExpReplace($sItem, "^\[\d+\]\|(.*)$", "$1")
                        EndIf
                        $sClip &= $sItem & @CRLF
                    Next
                EndIf
                ; Replace separator with required character
                $sClip = StringReplace($sClip, $sAD_Separator, $sUser_Separator)
                ; Send to clipboard
                ClipPut($sClip)
            Case $cUser_Func
                ; Check if function defined
                If $sUserFunc Then
                    ; Get selected indices
                    Local $aiCurItems2[1] = [0]
                    For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0)
                        If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then
                            $aiCurItems2[0] += 1
                            ReDim $aiCurItems2[$aiCurItems2[0] + 1]
                            $aiCurItems2[$aiCurItems2[0]] = $i
                        EndIf
                    Next
                    Call($sUserFunc, $avArray, $aiCurItems2)
                EndIf
            Case $cExit_Script
                Exit
        EndSwitch
    WEnd
    GUIDelete($hGUI)

    Opt("GUIOnEventMode", $iOnEventMode)
    Opt("GUIDataSeparatorChar", $sCurr_Separator) ; Reset original separator

    Return 1

EndFunc   ;==>_ArrayDisplay_Beta

; UDF code ends here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Func _UserFunc($aArray, $aSelected)
    MsgBox($MB_SYSTEMMODAL, "Hi", "Running the user defined function with " & @NumParams & " parameters.")
    For $i = 1 To $aSelected[0]
        ConsoleWrite($aSelected[$i] & "|" & $aArray[$aSelected[$i]][0] & @LF)
    Next

EndFunc   ;==>_UserFunc
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

- 4. Script-breaking If an error occurs because the UDF was not passed a 1D/2D array, a MsgBox will appear announce this rather than just returning an error and continuing the script as before. So the user does not need to add error checking code in their script as the UDF does this for them. This was added as the general opinion seemed to be that the function is basically intended for debugging and so it is useful to know that the array that was expected has not been created. The MsgBox offers a choice of exiting the script or of continuing - in which case it returns the same specific @error value as before.

 

Interesting options. :) People should avoid using _ArrayDisplay for anything other than debugging and testing.

  • Moderators
Posted

water,

I did think of something along those lines, but then where do you stop? What if the function has another purpose? I feel that leaving the function as an entirely separate entity from the UDF is the way to go. But as I pointed out in the other thread, there is nothing to prevent people amending the code to suit their personal circumstances. ;)

czardas,

 

People should avoid using _ArrayDisplay for anything other than debugging and testing

Not necessarily - although I feel that a purpose-built dialog would be a better solution if you needed to display an array as part of the main functionality of the script. And there is nothing to prevent the user from error-checking the array before using the UDF to prevent an error MsgBox appearing. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

czardas,

 

Not necessarily - although I feel that a purpose-built dialog would be a better solution if you needed to display an array as part of the main functionality of the script.

 

Well I guess it's a personal choice. Nice to see someone else using private zone unicode as delimiters. :thumbsup:

Posted

Melba,

You're getting closer to perfection every day Angel.png

That's a second pair of wings!

Just one thing that you probably already have in mind: make 0xF123 into a @ constant in Array.au3.

I strongly hope this particular value doesn't cause problems in the real-world, but I'd be surprised if a significant number of AutoIt users would hit a block with it. None of the known organizations(*) which have been coordinating use of Unicode PUAs (Private Use Area) seem to have mapped anything in the vincinity of 0xF123, yet the value has "some" mnemotechnic advantage.

(*) PUA basic information here, with known organizations.

 

 

People should avoid using _ArrayDisplay for anything other than debugging and testing.

I see no good reason for that. On the contrary, this enhanced version is even more useable in some applications where painfully coding a dedicated GUI just for displaying an array is pointless or wasteful.

For instance, when your application allows the user to custom-query a database: building a specific GUI once for all for displaying very variable results can turn into an always-instable nightmare. Instead this display can be enough for this purpose.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)

@jchd - Point conceded. :bike:

I don't even come close to 0xF123 (well actually :ermm: ).

Edit

Setting 0xF123 as an array constant unicode delimiter character in Array.au3 could potentially break one of my CSV functions - if that's what you mean. It's an easy fix, but please warn me before you do something like that.

Edited by czardas
  • Moderators
Posted

jchd,

 

make 0xF123 into a @ constant in Array.au3

All in good time - let us get the function agreed and approved first! :whistle:

 

I strongly hope this particular value doesn't cause problems in the real-world

Well, you suggested that value, so on your head be it! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

If it is so, then czardas will have to recommend another value in the BMP-0. From what I can gather, the range 0xF000-0xF7FF is not referenced by various entities, which leaves plenty of room for choice.

We certainly don't want to piss off czardas and ruin his project: the familly prevails! OTOH I'm pretty sure that such use of unassigned codepoints is exceptional.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

  • Moderators
Posted

czardas,

By all means suggest another code point to use here. As I said, I am only using this one because jchd suggested it and so I am entirely open to using another. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Please don't get mad. I just checked my code and I am using the delimiters in conjunction with native functions and not with Array UDF functions. Consequently I won't need to modify anything at all. My mistake, - I couldn't remember exactly what I was doing with them.

As far as the value goes, I think it's a good choice. :) I would have been more than happy to write an exception in my own code had there been any conflicts. Thanks for your responces.

Edited by czardas
  • Moderators
Posted

czardas,

 

Please don't get mad

Not a chance. Glad it is resolved. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

czardas secretly wanted 0xF666 but didn't dare say so :evil:

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

For instance, when your application allows the user to custom-query a database: building a specific GUI once for all for displaying very variable results can turn into an always-instable nightmare. Instead this display can be enough for this purpose.

I have something exactly like that i can use this for

czardas secretly wanted 0xF666 but didn't dare say so :evil:

 

Well the Devil is in the detail

Posted

water,

I did think of something along those lines, but then where do you stop? What if the function has another purpose? I feel that leaving the function as an entirely separate entity from the UDF is the way to go. But as I pointed out in the other thread, there is nothing to prevent people amending the code to suit their personal circumstances. ;)

Melba,

I think passing the array and the selected rows is all _ArrayDisplay can and should offer.

The main purpose of this function is for debugging. Imagine you notice some invalid data in a big array while debugging and want to save those records for further inspection.

Select them and then click the "user function" button to save the selected rows to a file.

I haven't followed all threads but can't imagine a useful user function without having some information about the displayed array or the selected rows.

Just my 2 cents worth ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I'm with water on this, this is a debugging function, and using it for anything beyond that is out of its scope. This function is already far larger than it needs to be, and getting bigger every time someone wants it to do something it isn't supposed to be used for. As stated in the other thread in GH&S, this function, as written, won't even display all the entries of an array if it is larger than 64000 rows, so if you're dealing with anything larger than that, or displaying a gui with a lot of controls, this function won't work for you anyways.

Basically what I've seen in comments regarding this function goes something like this, "I'm too lazy, or too inept, or too unskilled, to create my own listview to display my array, someone should modify this function to do it for me!!!", this is not what debugging functions are for, and this is WELL beyond the scope of the function.

The ONLY things I would have changed in this function was autosizing the GUI and columns to be able to fully display the contents of the columns, and removing the 64000 limit that was imposed on this function a couple of release versions back that was unnecessary.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

While I don't find it useful to overly turbocharge this function, I still don't regard it as a pure debugging function. It was in fact never considered such, else it would have been placed in Debug Management, not in Array Management.

About the 64K rows limit, I don't see any practical use of displaying that many rows, that it be for routine display of information in applications that deserve it nor in debugging anything in the practical world, like the one I live in.

In my view this enhanced version is very, very close to what can be expected from a standard UDF, with enough flexibility to fit most purposes.

And no, I don't feel particularly lazy or inept when using it and, should that be, I really don't give a damn on preachy opinions.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

While I don't find it useful to overly turbocharge this function, I still don't regard it as a pure debugging function. It was in fact never considered such, else it would have been placed in Debug Management, not in Array Management.

That's not true, it's been discussed many times about moving this to the debug udf because that's what this is supposed to be used for. It has no other practical use as written and should have been in debug.au3 a long time ago.

 

About the 64K rows limit, I don't see any practical use of displaying that many rows, that it be for routine display of information in applications that deserve it nor in debugging anything in the practical world, like the one I live in.

Now you're contradicting yourself, is it a debugging function or not? If it's a debugging function then the row limit doesn't cause an issue, if it's to be used for something else then the row limit can be a problem.

In my view this enhanced version is very, very close to what can be expected from a standard UDF, with enough flexibility to fit most purposes.

 

And no, I don't feel particularly lazy or inept when using it and, should that be, I really don't give a damn on preachy opinions.

If I'm going to want to display an array in a listview, for anything other than a quick debug to see what the array contains after creating/adding to the array, then I use this. If I want to do anything else with this information, I create a purpose-built listview function to handle that specific need. A catch-all array function like this is usually inadequate for the job, and asking it to do more is out of scope of what it was created to do.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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