Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#3739 closed Feature Request (Completed)

Scripting.dictionary Keys/Items array support for _ArrayDisplay

Reported by: Beege Owned by: J-Paul Mesnage
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 by Beege, 6 years ago

Sorry the component should be Standard UDFs for this

comment:2 by mLipok, 6 years ago

Component: AutoItStandard UDFs
Description: modified (diff)

comment:3 by J-Paul Mesnage, 6 years ago

Owner: set to mLipok
Status: newassigned

comment:4 by J-Paul Mesnage, 6 years ago

Milestone: 3.3.15.4
Owner: changed from mLipok to J-Paul Mesnage
Resolution: Completed
Status: assignedclosed

Added by revision [12378] in version: 3.3.15.4

comment:5 by J-Paul Mesnage, 6 years ago

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

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.