Modify

Opened 2 years ago

Closed 17 months ago

Last modified 17 months ago

#3739 closed Feature Request (Completed)

Scripting.dictionary Keys/Items array support for _ArrayDisplay

Reported by: Beege Owned by: Jpm
Milestone: 3.3.15.4 Component: Standard UDFs
Version: Severity: None
Keywords: _Arraydisplay scripting.dictionary Cc:

Description (last modified by mLipok)

I wanted to ask for this years ago but at the time _arraydisplay was stand alone function and I thought it was a bit much to ask to make it a sub function just to support this. I also couldn't see asking for _dictionarydisplay because where would it go? I see now that _arraydisplay has had an overhall and is using a shared sub function so this would be real easy to add by throwing the keys and items arrays together into a temp 2D array before calling shared function. Same idea could be done with maps as well.

#include <array.au3>

$oDi = ObjCreate('scripting.dictionary')
For $i = 0 to 10
        $oDi.Add('key' & $i,'item' & $i)
Next
ArrayDisplay($oDi)


Func ArrayDisplay(Const ByRef $aArray, $sTitle = Default, $sArrayRange = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default)
        #forceref $vUser_Separator

        If IsObj($aArray) And StringInStr(ObjName($aArray, 3), 'scripting.dictionary') Then

                Local $aTmp[$aArray.Count][2], $aK = $aArray.Keys, $aI = $aArray.Items
                For $i = 0 To $aArray.Count - 1
                        $aTmp[$i][0] = $aK[$i]
                        $aTmp[$i][1] = $aI[$i]
                Next

                If $sHeader = Default Then $sHeader = 'Keys|Items'
                If $sTitle = Default Then $sTitle = 'DictionaryDisplay'

                Local $iRet = __ArrayDisplay_Share($aTmp, $sTitle, $sArrayRange, $iFlags, Default, $sHeader, $iMax_ColWidth, 0, False)
        Else
                Local $iRet = __ArrayDisplay_Share($aArray, $sTitle, $sArrayRange, $iFlags, Default, $sHeader, $iMax_ColWidth, 0, False)
        EndIf
        Return SetError(@error, @extended, $iRet)
EndFunc   ;==>ArrayDisplay

Attachments (0)

Change History (5)

comment:1 Changed 2 years ago by Beege

Sorry the component should be Standard UDFs for this

comment:2 Changed 2 years ago by mLipok

  • Component changed from AutoIt to Standard UDFs
  • Description modified (diff)

comment:3 Changed 21 months ago by Jpm

  • Owner set to mLipok
  • Status changed from new to assigned

comment:4 Changed 17 months ago by Jpm

  • Milestone set to 3.3.15.4
  • Owner changed from mLipok to Jpm
  • Resolution set to Completed
  • Status changed from assigned to closed

Added by revision [12378] in version: 3.3.15.4

comment:5 Changed 17 months ago by Jpm

In fact a _aaray2DCreate() is added to not polluted _ArrayDisplay()

#include <Array.au3>

Local $oDi = ObjCreate('scripting.dictionary')
For $i = 0 To 10
	$oDi.Add('key' & $i, 'item' & $i)
Next

_ArrayDisplay(_Array2DCreate($oDi.Keys, $oDi.Items))

Func _Array2DCreate($aCol0, $aCol1)
	If (UBound($aCol0, 0) <> 1) Or (UBound($aCol1, 0) <> 1) Then Return SetError(1, 0, "")
	Local $nRows = UBound($aCol0)
	If $nRows <> UBound($aCol1) Then Return SetError(2, 0, "")
	Local $aTmp[$nRows][2]
	For $i = 0 To $nRows - 1
		$aTmp[$i][0] = $aCol0[$i]
		$aTmp[$i][1] = $aCol1[$i]
	Next
	Return $aTmp
EndFunc   ;==>_Array2DCreate

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.