Hallo,
ich versuche gerade eine Inidatei in einen 3D Array einlesen zu lassen. Im Moment bin ich so weit:
Spoiler anzeigen
Func _IniReadToArray($i_File)
[/autoit] [autoit][/autoit] [autoit]Dim $i_Array[1][2][1]
[/autoit] [autoit][/autoit] [autoit]$i_IniReadSectionNames = IniReadSectionNames($i_File)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]For $i_Loop = 1 To $i_IniReadSectionNames[0]
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]ReDim $i_Array[UBound($i_Array, 1)][UBound($i_Array, 2)][$i_Loop]
$i_Array[0][0][$i_Loop - 1] = $i_IniReadSectionNames[$i_Loop]
$i_Section = IniReadSection($i_File, $i_IniReadSectionNames[$i_Loop])
[/autoit] [autoit][/autoit] [autoit]For $i_Loop2 = 1 To $i_Section[0][0]
[/autoit] [autoit][/autoit] [autoit]ReDim $i_Array[$i_Loop2 + 1][UBound($i_Array, 2)][UBound($i_Array, 3)]
[/autoit] [autoit][/autoit] [autoit]$i_Array[$i_Loop2 - 1][0][$i_Loop - 1] = $i_Section[$i_Loop2][0]
$i_Array[$i_Loop2 - 1][1][$i_Loop - 1] = $i_Section[$i_Loop2][1]
Next
Next
_ArrayDisplayTree($i_Array, 0, "Array In Array")
EndFunc ;==>_IniReadToArray
_ArrayDisplayTree.au3
#include <GuiImageList.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
Func _ArrayDisplayTree($aArray, $iExpand = 1, $sTitle = "Array: TreeView Display", $sDimension = "", $sElement = "", $iWidth = 380, $iHeight = 640, $iRootColor = 0xCC0000, $iDimensionColor = 0x00AA00, $iElementColor = 0x0000FF)
;By Eukalyptus ![]()
If Not IsArray($aArray) Then Return SetError(1, 0, 0)
Local $iEventMode = Opt("GUIOnEventMode", 0)
Local $aIndex[UBound($aArray, 0) + 1], $sRoot = "Array "
$aIndex[0] = 1
For $i = 1 To UBound($aArray, 0)
$aIndex[$i] = "0"
$aIndex[0] *= UBound($aArray, $i)
$sRoot &= "[" & UBound($aArray, $i) & "]"
Next
Local $hGui = GUICreate($sTitle, $iWidth, $iHeight, Default, Default, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
Local $iStyle = BitOR($TVS_DISABLEDRAGDROP, $TVS_HASBUTTONS, $TVS_LINESATROOT)
Local $hTreeView = GUICtrlCreateTreeView(2, 2, $iWidth - 4, $iHeight - 26, $iStyle)
Local $hParent = GUICtrlCreateTreeViewItem($sRoot, $hTreeView)
GUICtrlSetColor(-1, $iRootColor)
Local $hImageList = _GUIImageList_Create(11, 11)
_GUIImageList_Add($hImageList, _GUICtrlTreeView_CreateSolidBitMap($hTreeView, 0x666666, 11, 11))
_GUIImageList_Add($hImageList, _GUICtrlTreeView_CreateSolidBitMap($hTreeView, 0xAA0000, 11, 11))
_GUIImageList_Add($hImageList, _GUICtrlTreeView_CreateSolidBitMap($hTreeView, 0x00AA00, 11, 11))
_GUIImageList_Add($hImageList, _GUICtrlTreeView_CreateSolidBitMap($hTreeView, 0x0000CC, 11, 11))
_GUIImageList_Add($hImageList, _GUICtrlTreeView_CreateSolidBitMap($hTreeView, 0xFFAA00, 11, 11))
_GUIImageList_Add($hImageList, _GUICtrlTreeView_CreateSolidBitMap($hTreeView, 0xFF00FF, 11, 11))
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList)
Local $hProgress = GUICtrlCreateProgress(2, $iHeight - 20, $iWidth - 4, 18, 0x1)
GUISetState()
_GUICtrlTreeView_BeginUpdate($hTreeView)
_ArrayDisplayTreeAddItems($aArray, $hTreeView, $hParent, $aIndex, $hProgress, 0, $iRootColor, $iDimensionColor, $iElementColor, $sDimension, $sElement)
_GUICtrlTreeView_Expand($hTreeView, $hParent, False)
_GUICtrlTreeView_EndUpdate($hTreeView)
Switch $iExpand
Case 1
_GUICtrlTreeView_Expand($hTreeView, $hParent)
Case 2
Local $sExpand = "#0", $hTree = ControlGetHandle($hGui, "", $hTreeView)
For $i = 0 To UBound($aIndex) - 1
ControlTreeView($hGui, "", $hTree, "Expand", $sExpand)
$sExpand &= "|#0"
Next
Case Else
Local $hTree = ControlGetHandle($hGui, "", $hTreeView)
ControlTreeView($hGui, "", $hTree, "Expand", "#0")
EndSwitch
GUICtrlSetData($hProgress, 0)
While GUIGetMsg() <> -3
WEnd
GUIDelete($hGui)
Opt("GUIOnEventMode", $iEventMode)
EndFunc ;==>_ArrayDisplayTree
Func _ArrayDisplayTreeAddItems($aArray, $hTreeView, $hParent, $aIndex, $hProgress, $iStep, $iRootColor, $iDimensionColor, $iElementColor, $sDim, $sEle)
Local $sExexute = "$aArray", $sElement = $sEle, $sDimension, $Temp, $hItem
$hItem = $hParent
For $i = 1 To UBound($aArray, 0) - 1
$Temp = _GUICtrlTreeView_GetItemByIndex($hTreeView, $hItem, $aIndex[$i])
If $Temp = 0 Then
$sDimension = $sDim
For $j = 1 To UBound($aIndex) - 1
Switch $j
Case $i
$sDimension &= "[" & $aIndex[$i] & "] "
Case Else
$sDimension &= "_ "
EndSwitch
Next
$hItem = GUICtrlCreateTreeViewItem($sDimension, $hItem)
GUICtrlSetColor(-1, $iDimensionColor)
_GUICtrlTreeView_SetImageIndex($hTreeView, $hItem, Mod($i, 4) + 1)
Else
_GUICtrlTreeView_SelectItem($hTreeView, $Temp, $TVGN_CARET)
$hItem = GUICtrlRead($hTreeView)
EndIf
$sExexute &= "[" & $aIndex[$i] & "] "
$sElement &= "[" & $aIndex[$i] & "] "
Next
For $i = 1 To UBound($aArray, UBound($aArray, 0));-1
$Temp = Execute($sExexute & "[" & $i - 1 & "]")
If IsArray($Temp) Then
Local $aElementIndex[UBound($Temp, 0) + 1], $sRoot = "Array ", $hElementItem
$aElementIndex[0] = 1
For $j = 1 To UBound($Temp, 0)
$aElementIndex[$j] = "0"
$aElementIndex[0] *= UBound($Temp, $j)
$sRoot &= "[" & UBound($Temp, $j) & "]"
Next
$hElementItem = GUICtrlCreateTreeViewItem($sElement & "[" & $i - 1 & "] = <" & $sRoot & ">", $hItem)
GUICtrlSetColor(-1, $iRootColor)
_GUICtrlTreeView_SetImageIndex($hTreeView, $hElementItem, 5)
_ArrayDisplayTreeAddItems($Temp, $hTreeView, $hElementItem, $aElementIndex, $hProgress, 0, $iRootColor, $iDimensionColor, $iElementColor, "SUB " & $sDim, "SUB " & $sEle)
ContinueLoop
EndIf
$Temp = GUICtrlCreateTreeViewItem($sElement & "[" & $i - 1 & "] = <" & $Temp & ">", $hItem)
GUICtrlSetColor(-1, $iElementColor)
_GUICtrlTreeView_SetImageIndex($hTreeView, $Temp, 5)
$iStep += 1
Next
GUICtrlSetData($hProgress, $iStep * 100 / $aIndex[0])
$Temp = UBound($aIndex) - 1
Switch $Temp
Case 1
Return
Case 2
$aIndex[$Temp - 1] += 1
If $aIndex[1] >= UBound($aArray, 1) Then Return
Case Else
$aIndex[$Temp - 1] += 1
For $i = $Temp To 2 Step -1
Switch 1
Case $aIndex[$i] >= UBound($aArray, $i)
$aIndex[$i] = 0
$aIndex[$i - 1] += 1
If $aIndex[1] >= UBound($aArray, 1) Then Return
If $aIndex[$i - 1] >= UBound($aArray, $i - 1) Then ContinueLoop
EndSwitch
Next
EndSwitch
_ArrayDisplayTreeAddItems($aArray, $hTreeView, $hParent, $aIndex, $hProgress, $iStep, $iRootColor, $iDimensionColor, $iElementColor, $sDim, $sEle)
EndFunc ;==>_ArrayDisplayTreeAddItems
Ich möchte nämlich einen Array nach folgendem Schema erzeugen:
$Array[0][0][1] ==> Sectionname
$Array[0][1][0] ==> 0 = Key, 1 = Value
$Array[1][0][0] ==> Key oder Value
Doch irgendwie habe ich da meine Probleme mit 3D Arrays, da ich sie nicht so oft benutze (fast nie).
Als 2D Array ist es mir nicht übersichtlich genug...
Ich hoffe jemand kann dieses Problem lösen ich blicke da bei diesen ganzen Array-Dinger nicht mehr durch :wacko: