Jump to content

Recommended Posts

Posted (edited)

Ever wanted to debug up to a 3d array? (can be modified to create window for any number of dimentions; was also thinking about adding links for array in arrays)
 

#include <ListviewConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Local $aTest[3][2][3] = [[["aa1", "aa2", "aa3"],["ab1", "ab2", "ab3"]],[["ba1", "ba2", "ba3"],["bb1", "bb2", "bb3"]],[["ca1", "ca2", "ca3"],["cb1", "cb2", "cb3"]]]
;~ Local $aTest[2][3] =[["aa1", "aa2", "aa3"],["ab1", "ab2", "ab3"]]
_3DArrayDisplay($aTest)
Func _3DArrayDisplay($aCallersArray)
 $iGuiHeight = 400
 $iGuiWidth = 400
 $hgui = GUICreate("3D Array", $iGuiWidth, $iGuiHeight)
 $i1D_Ubound = UBound($aCallersArray)
 $i2D_Ubound = UBound($aCallersArray, 2)
 $i3D_Ubound = UBound($aCallersArray, 3)
 If @error Then
  _ArrayDisplay($aCallersArray)
  Return $aCallersArray
 EndIf
 Local Enum $i2DHolder_TabControl, $i2DHolder_Array, $i2DHolder_UBound
 Local $a2DHolder[$i1D_Ubound][$i2DHolder_UBound]
 For $i = 0 To $i1D_Ubound - 1
  Local $aTemp[$i2D_Ubound][$i3D_Ubound]
  For $j = 0 To 1
   For $k = 0 To 2
    $aTemp[$j][$k] = $aCallersArray[$i][$j][$k]
   Next
  Next
  $a2DHolder[$i][$i2DHolder_Array] = $aTemp
 Next
 GUICtrlCreateTab(10, 10, $iGuiWidth - 20, $iGuiHeight - 20)
 For $i = 0 To UBound($a2DHolder) - 1
  $aTemp = $a2DHolder[$i][$i2DHolder_Array]
  $a2DHolder[$i][$i2DHolder_TabControl] = GUICtrlCreateTabItem("Dimension" & $i)
  $breaks = "Column0"
  For $j = 0 To UBound($aTemp, 2) - 2
   $breaks &= "|Column" & $j + 1
  Next
  $iListView = GUICtrlCreateListView($breaks, 20, 40, $iGuiWidth - 40, $iGuiHeight - 60, -1, $LVS_EX_GRIDLINES)
  For $j = 0 To UBound($aTemp) - 1
   For $k = 0 To UBound($aTemp, 2) - 1
    If $k = 0 Then
     $string = $aTemp[$j][$k]
    Else
     $string = $string & "|" & $aTemp[$j][$k]
    EndIf
   Next
   ConsoleWrite($string & @CRLF)
   GUICtrlCreateListViewItem($string, $iListView)
  Next
 Next
 GUISetState(@SW_SHOW)
 Do
  Local $msg = GUIGetMsg()
 Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>_3DArrayDisplay

edit: when the forum updated, it killed the @error on line 23...just updated

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

Another way (I have not searched if it has already been done) :

#include <GUIConstantsEx.au3>

Local $aArray3D[3][2][3] = [ _
        [ _
            ["aa1", "aa2", "aa3"], _
            ["ab1", "ab2", "ab3"] _
        ], _
        [ _
            ["ba1", "ba2", "ba3"], _
            ["bb1", "bb2", "bb3"] _
        ], _
        [ _
            ["ca1", "ca2", "ca3"], _
            ["cb1", "cb2", "cb3"] _
        ] _
    ]

_ArrayDisplayTreeView($aArray3D)

Func _ArrayDisplayTreeView(ByRef $avArray, $blExpandAll = True)
    Local Const $iUBound_1D = UBound($avArray, 1)
    Local Const $iUBound_2D = UBound($avArray, 2)
    Local Const $iUBound_3D = UBound($avArray, 3)

    Local Const $hGUI = GUICreate("Array TreeView Display", 400, 550)

    Local Const $iTreeView = GUICtrlCreateTreeView(10, 10, 380, 530)
    Local Const $iSubTree1D = GUICtrlCreateTreeViewItem("Array (" & $iUBound_1D & ")", $iTreeView)

    Local $iSubTree2D = 0, $iSubTree3D = 0

    For $i_1D = 0 To $iUBound_1D -1
        If $iUBound_2D = 0 Then
            GUICtrlCreateTreeViewItem($avArray[$i_1D], $iSubTree1D)
            ContinueLoop
        EndIf

        $iSubTree2D = GUICtrlCreateTreeViewItem("Array (" & $iUBound_2D & ")", $iSubTree1D)

        For $i_2D = 0 To $iUBound_2D -1
            If $iUBound_3D = 0 Then
                GUICtrlCreateTreeViewItem($avArray[$i_1D][$i_2D], $iSubTree2D)
                ContinueLoop
            EndIf

            $iSubTree3D = GUICtrlCreateTreeViewItem("Array (" & $iUBound_3D & ")", $iSubTree2D)

            For $i_3D = 0 To $iUBound_3D -1
                GUICtrlCreateTreeViewItem($avArray[$i_1D][$i_2D][$i_3D], $iSubTree3D)
            Next

            If $blExpandAll Then GUICtrlSetState($iSubTree3D, $GUI_EXPAND)
        Next

        If $blExpandAll Then GUICtrlSetState($iSubTree2D, $GUI_EXPAND)
    Next

    GUICtrlSetState($iSubTree1D, $GUI_EXPAND)

    GUISetState(@SW_SHOW, $hGUI)

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
        Sleep(10)
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>_3DArrayDisplay
Edited by FireFox
Posted

Nice examples.

I'll stick with 2D arrays though for me, way too confusing once you get too far off the norm at my age. :)

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 (edited)

Very nice example. :) I wonder what the practical limits would be for this - I suppose it depends on how many tabs you can create, and screen resolution.

I had a go at this My second example is better than the first. I think my code needs to be rewritten, although the implimentation is quite confusing.

Edited by czardas

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
  • Recently Browsing   0 members

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