wolf9228 Posted December 24, 2014 Share Posted December 24, 2014 CArray Third VersionCArray.zip CArray.au3expandcollapse popup#include <GuiListView.au3> #include <GUIConstantsEx.au3> Global $UNICODE = True ; BOOL $UNICODE Global $BinaryToStruct = True ;BOOL $BinaryToStruct True Fast // $tagStruct = "BYTE Binary[" & $BinaryLen & "]" Global $ByteSize=DllStructGetSize(DllStructCreate("BYTE")),$DoubleSize=DllStructGetSize(DllStructCreate("DOUBLE")) Global $OleAut32 = DllOpen("OleAut32.dll") , $Msvcrt = DllOpen("msvcrt.dll") , $kernel32 = DllOpen("kernel32.dll") Func CArray1D($RowsCount) If $RowsCount < 1 Then Return SetError(1,0,0) $CArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowsCount & "];DOUBLE ELEMENTS[" & $RowsCount & "]") DllStructSetData($CArray1D,1,$RowsCount) Return $CArray1D EndFunc Func UBound1D(ByRef $CArray1D) $RE = DllStructGetData($CArray1D,"RE") if ($RE = 0) Then Return SetError(1,0,0) Return $RE EndFunc Func ReDim1D(ByRef $CArray1D,$RowsCount) Local $iRowsCount = DllStructGetData($CArray1D, 1) Local $TestBool = $iRowsCount > 0 And $RowsCount > 0 Select Case $TestBool And $RowsCount > $iRowsCount Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowsCount & "];DOUBLE ELEMENTS[" & $RowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = ($DoubleSize * $iRowsCount) Local $SizeB = $iRowsCount ;($ByteSize * $iRowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$RowsCount) $CArray1D = $NewCArray1D Return True Case $TestBool And $RowsCount < $iRowsCount Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowsCount & "];DOUBLE ELEMENTS[" & $RowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowsCount Local $SizeB = $RowsCount ;($ByteSize * $RowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) For $i = ($RowsCount + 1) To $iRowsCount If (DllStructGetData($CArray1D,2,$i) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$i)) Next DllStructSetData($NewCArray1D,1,$RowsCount) $CArray1D = $NewCArray1D Return True Case ($TestBool) And ($RowsCount = $iRowsCount) Return True EndSelect Return SetError(1,0,False) EndFunc Func GetAt1D(ByRef $CArray1D,$RowIndex) $RowIndex += 1 Switch DllStructGetData($CArray1D,"DATATYPE",$RowIndex) Case 8 $LPVOID = DllStructGetData($CArray1D,3,$RowIndex) $String = DllCall($Msvcrt,"WSTR:CDECL","wcscpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case 7 $LPVOID = DllStructGetData($CArray1D,3,$RowIndex) $String = DllCall($Msvcrt , "STR:CDECL" ,"strcpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case 6 $LPVOID = DllStructGetData($CArray1D,3,$RowIndex) $BinaryLen = DllCall($OleAut32,"UINT","SysStringByteLen","PTR",$LPVOID) Switch $BinaryToStruct Case True Return DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID) Case False Return DllStructGetData(DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID),1) EndSwitch Case 5 Return DllStructGetData($CArray1D,3,$RowIndex) Case 4 Return DllStructGetData($CArray1D,3,$RowIndex) Case 3 Return DllStructGetData($CArray1D,3,$RowIndex) <> 0 Case 2 Return Ptr(DllStructGetData($CArray1D,3,$RowIndex)) Case 1 Return Default EndSwitch if @error Then Return SetError(1,0,"") ; error For DllStructGetData($CArray1D,"DATATYPE",$RowIndex) Return "" ; Null Values EndFunc Func SetAt1D(ByRef $CArray1D,$RowIndex,$vValue) $RowIndex += 1 Local $DataType = DllStructGetData($CArray1D,2,$RowIndex) Select Case IsString($vValue) Switch $UNICODE Case True if DllStructSetData($CArray1D,2,8,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) DllStructSetData($CArray1D,3,$LPVOID[0],$RowIndex) Return True Case False if DllStructSetData($CArray1D,2,7,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) DllStructSetData($CArray1D,3,$LPVOID[0],$RowIndex) Return True EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) if DllStructSetData($CArray1D,2,6,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) DllStructSetData($CArray1D,3,$LPVOID,$RowIndex) Return True Case IsInt($vValue) if DllStructSetData($CArray1D,2,5,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsFloat($vValue) if DllStructSetData($CArray1D,2,4,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsBool($vValue) if DllStructSetData($CArray1D,2,3,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsPtr($vValue) if DllStructSetData($CArray1D,2,2,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsKeyword($vValue) ;Default Keyword if DllStructSetData($CArray1D,2,1,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) Return True EndSelect Return SetError(2,0,False) EndFunc Func SetWithReDim1D(ByRef $CArray1D,$RowIndex,$vValue) $RowIndex += 1 Local $RowsCount = DllStructGetData($CArray1D,"RE"),$DataType = 0 Select Case $RowsCount = 0 Or $RowIndex < 1; Failure For DllStructGetData($CArray1D,"RE") Or $RowIndex < 1 Return SetError(1,0,False) Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(2,0,False) Case $RowIndex <= $RowsCount if DllStructGetData($CArray1D,2,$RowIndex) > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,2,$DataType,$RowIndex) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case $RowIndex > $RowsCount ;----------------ReDim--------------------------------- Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowIndex & "];DOUBLE ELEMENTS[" & $RowIndex & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowsCount Local $SizeB = $RowsCount;($ByteSize * $RowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$RowIndex) ;----------------ReDim--------------------------------- $CArray1D = $NewCArray1D DllStructSetData($CArray1D,2,$DataType,$RowIndex) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True EndSelect EndFunc Func Add1D(ByRef $CArray1D,$vValue,$End = True) Local $iRowsCount = DllStructGetData($CArray1D , 1 ) Local $NRowsCount = $iRowsCount + 1 ,$DataType = 0 Select Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(1,0,False) Case $End = True And $iRowsCount > 0 Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $NRowsCount & "];DOUBLE ELEMENTS[" & $NRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $iRowsCount Local $SizeB = $iRowsCount ;($ByteSize * $iRowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$NRowsCount) DllStructSetData($NewCArray1D,2,$DataType,$NRowsCount) DllStructSetData($NewCArray1D,3,$vValue,$NRowsCount) $CArray1D = $NewCArray1D Return True Case $End = False And $iRowsCount > 0 Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $NRowsCount & "];DOUBLE ELEMENTS[" & $NRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $iRowsCount Local $SizeB = $iRowsCount ;($ByteSize * $iRowsCount) Local $SizeC = $DoubleSize ;($DoubleSize * 1) Local $SizeD = $ByteSize ;($ByteSize * 1) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeD,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$NRowsCount) DllStructSetData($NewCArray1D,2,$DataType,1) DllStructSetData($NewCArray1D,3,$vValue,1) $CArray1D = $NewCArray1D Return True EndSelect if ($DataType > 5) Then DllCall($OleAut32,"NONE","SysFreeString","PTR",$vValue) Return SetError(2,0,False) EndFunc Func InsertAt1D(ByRef $CArray1D,$RowIndex,$vValue) Local $iRowsCount = DllStructGetData($CArray1D,1),$NRowIndex = ($RowIndex + 1) Local $NRowsCount = $iRowsCount + 1 , $DataType = 0 Select Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(1,0,False) Case $iRowsCount > 0 And $NRowIndex > 0 And $NRowIndex <= $iRowsCount Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $NRowsCount & "];DOUBLE ELEMENTS[" & $NRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowIndex DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) Local $SizeB = $DoubleSize * $NRowIndex Local $SizeC = $DoubleSize * $RowIndex Local $SizeD = $DoubleSize * ($iRowsCount - $RowIndex) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeB,"PTR",$ElementsPtr + $SizeC,"ULONG_PTR",$SizeD) Local $SizeE = $RowIndex;($ByteSize * ($RowIndex)) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) Local $SizeF = $NRowIndex;($ByteSize * $NRowIndex) Local $SizeG = $RowIndex;($ByteSize * $RowIndex ) Local $SizeH = $iRowsCount - $RowIndex;($ByteSize * ($iRowsCount - $RowIndex)) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr + $SizeG,"ULONG_PTR",$SizeH) DllStructSetData($NewCArray1D,1,$NRowsCount) DllStructSetData($NewCArray1D,2,$DataType,$NRowIndex) DllStructSetData($NewCArray1D,3,$vValue,$NRowIndex) $CArray1D = $NewCArray1D Return True EndSelect if ($DataType > 5) Then DllCall($OleAut32,"NONE","SysFreeString","PTR",$vValue) Return SetError(2,0,False) EndFunc Func DeleteAt1D(ByRef $CArray1D,$RowIndex) Local $iRowsCount = DllStructGetData($CArray1D,1) if $RowIndex < 0 Or $RowIndex > $iRowsCount - 1 _ Or $iRowsCount = 0 Then Return SetError(1,0,False) Local $nRowsCount = $iRowsCount - 1 Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $nRowsCount & "];DOUBLE ELEMENTS[" & $nRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowIndex DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) Local $SizeB = $DoubleSize * ($iRowsCount - ($RowIndex + 1)) Local $SizeC = $DoubleSize * $RowIndex Local $SizeD = $DoubleSize * ($RowIndex + 1) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr + $SizeD,"ULONG_PTR",$SizeB) Local $SizeE = $RowIndex;($ByteSize * $RowIndex) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) Local $SizeF = $iRowsCount - ($RowIndex + 1);($ByteSize * ($iRowsCount - ($RowIndex + 1))) Local $SizeG = $RowIndex;($ByteSize * $RowIndex) Local $SizeH = $RowIndex + 1;($ByteSize * ($RowIndex - 1)) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeG,"PTR",$DataTypePtr + $SizeH,"ULONG_PTR" ,$SizeF) DllStructSetData($NewCArray1D,1,$nRowsCount) $RowIndex += 1 if (DllStructGetData($CArray1D,2,$RowIndex) > 5) Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $CArray1D = $NewCArray1D Return True EndFunc Func FreeCArray1D(ByRef $CArray1D) Local $iRowsCount = DllStructGetData($CArray1D,"RE") if ($iRowsCount = 0) Then Return SetError(1,0,False) ;If Failure For $i = 1 To $iRowsCount If DllStructGetData($CArray1D,2,$i) > 5 Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$i)) Next $CArray1D = CArray1D($iRowsCount) Return True EndFunc Func DeleteCArray1D(ByRef $CArray1D) Local $iRowsCount = DllStructGetData($CArray1D,"RE") if ($iRowsCount = 0) Then Return SetError(1,0,False) ;If Failure For $i = 1 To $iRowsCount If DllStructGetData($CArray1D,2,$i) > 5 Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$i)) Next $CArray1D = 0 Return True EndFunc Func CArray2D($RowsCount,$ColusCount) Select Case $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,0) Case Else Local $ElementsCount = $RowsCount * $ColusCount Local $CArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") DllStructSetData($CArray2D,1,$RowsCount) DllStructSetData($CArray2D,2,$ColusCount) Return $CArray2D EndSelect EndFunc Func UBound2D(ByRef $CArray2D , $Dimension = 1) Switch $Dimension Case 1 $RE = DllStructGetData($CArray2D,"RE") if ($RE = 0) Then Return SetError(1,0,0) Return $RE Case 2 $CE = DllStructGetData($CArray2D,"CE") if ($CE = 0) Then Return SetError(1,0,0) Return $CE Case Else Return SetError(2,0,0) EndSwitch EndFunc Func ReDim2D(ByRef $CArray2D,$RowsCount,$ColusCount) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Select Case $iRowsCount < 1 Or $RowsCount < 1 _ Or $iColusCount < 1 Or $iColusCount < 1 Return SetError(1,0,False) Case $ColusCount = $iColusCount And $RowsCount > $iRowsCount Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColusCount * $iRowsCount Local $SizeB = $ColusCount * $iRowsCount;( $ByteSize * ($ColusCount * $iRowsCount) ) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True Case $ColusCount = $iColusCount And $RowsCount < $iRowsCount Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColusCount * $RowsCount Local $SizeB = $ColusCount * $RowsCount;( $ByteSize * ($ColusCount * $RowsCount) ) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) For $i = $RowsCount + 1 To $iRowsCount For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True Case ($ColusCount > $iColusCount And $RowsCount >= $iRowsCount) Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $RowSizeA = $ColusCount * $DoubleSize Local $RowSizeB = $iColusCount * $DoubleSize Local $RowSizeC = $ColusCount ;* $ByteSize ) Local $RowSizeD = $iColusCount ;* $ByteSize ) For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$RowSizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$RowSizeD) $NewElementsPtr += $RowSizeA $ElementsPtr += $RowSizeB $NewDataTypePtr += $RowSizeC $DataTypePtr += $RowSizeD Next DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True Case $ColusCount = $iColusCount And $RowsCount = $iRowsCount Return True Case Else Local $pRowsCount = $iRowsCount , $pColusCount = $iColusCount If $RowsCount < $iRowsCount Then $pRowsCount = $RowsCount If $ColusCount < $iColusCount Then $pColusCount = $ColusCount Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $RowSizeA = $ColusCount * $DoubleSize Local $RowSizeB = $iColusCount * $DoubleSize Local $RowSizeC = $pColusCount * $DoubleSize Local $RowSizeD = $ColusCount ;* $ByteSize Local $RowSizeE = $iColusCount ;* $ByteSize Local $RowSizeF = $pColusCount ;* $ByteSize For $i = 1 To $iRowsCount Select Case $i <= $pRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$RowSizeC) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$RowSizeF) $NewElementsPtr += $RowSizeA $ElementsPtr += $RowSizeB $NewDataTypePtr += $RowSizeD $DataTypePtr += $RowSizeE For $j = ($pColusCount + 1) To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Case Else For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next EndSelect Next DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func GetAt2D(ByRef $CArray2D,$RowIndex,$ColuIndex) Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") $RowIndex += 1 $ColuIndex += 1 Local $ElementNu = ($RowIndex * $ColusCount) - ($ColusCount - $ColuIndex) Local $DataType = DllStructGetData( $CArray2D , 3 , $ElementNu ) Select Case $RowIndex < 1 Or $RowIndex > $RowsCount Or $ColuIndex < 1 _ Or $ColuIndex > $ColusCount Or $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,"") Case $DataType = 8 $LPVOID = DllStructGetData($CArray2D,4,$ElementNu) $String = DllCall($Msvcrt,"WSTR:CDECL","wcscpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case $DataType = 7 $LPVOID = DllStructGetData($CArray2D,4,$ElementNu) $String = DllCall($Msvcrt , "STR:CDECL" ,"strcpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case $DataType = 6 $LPVOID = DllStructGetData($CArray2D,4,$ElementNu) $BinaryLen = DllCall($OleAut32,"UINT","SysStringByteLen","PTR",$LPVOID) Switch $BinaryToStruct Case True Return DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID) Case False Return DllStructGetData(DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID),1) EndSwitch Case $DataType = 5 Return DllStructGetData($CArray2D,4,$ElementNu) Case $DataType = 4 Return DllStructGetData($CArray2D,4,$ElementNu) Case $DataType = 3 Return DllStructGetData($CArray2D,4,$ElementNu) <> 0 Case $DataType = 2 Return Ptr(DllStructGetData($CArray2D,4,$ElementNu)) Case $DataType = 1 Return Default EndSelect Return "" ; Null Values EndFunc Func SetAt2D(ByRef $CArray2D,$RowIndex,$ColuIndex,$vValue) Local $RowsCount = DllStructGetData($CArray2D,1) Local $ColusCount = DllStructGetData($CArray2D,2) $RowIndex += 1 $ColuIndex += 1 Local $ElementNu = ($RowIndex * $ColusCount) - ($ColusCount - $ColuIndex) Local $DataType = DllStructGetData($CArray2D,3,$ElementNu) Select Case $RowIndex < 1 Or $RowIndex > $RowsCount Or $ColuIndex < 1 _ Or $ColuIndex > $ColusCount Or $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,False) Case IsString($vValue) Switch $UNICODE Case True if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) DllStructSetData($CArray2D,3,8,$ElementNu) DllStructSetData($CArray2D,4,$LPVOID[0],$ElementNu) Return True Case False if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) DllStructSetData($CArray2D,3,7,$ElementNu) DllStructSetData($CArray2D,4,$LPVOID[0],$ElementNu) Return True EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) DllStructSetData($CArray2D,3,6,$ElementNu) DllStructSetData($CArray2D,4,$LPVOID,$ElementNu) Return True Case IsInt($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,5,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsFloat($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,4,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsBool($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,3,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsPtr($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,2,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsKeyword($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) ;Default Keyword DllStructSetData($CArray2D,3,1,$ElementNu) Return True EndSelect Return SetError(2,0,False) EndFunc Func SetWithReDim2D(ByRef $CArray2D,$RowIndex,$ColuIndex,$vValue) Local $DataType = 0 Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") $RowIndex += 1 $ColuIndex += 1 Select Case $RowIndex < 1 Or $ColuIndex < 1 Or $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,False) Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(2,0,False) Case $RowIndex <= $RowsCount And $ColuIndex <= $ColusCount Local $ElementNu = ($RowIndex * $ColusCount) - ($ColusCount - $ColuIndex) if (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,$DataType,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case $ColuIndex = $ColusCount And $RowIndex > $RowsCount ;-------------------------------------------ReDim--------------------------------------------------------- Local $ElementsCount = $RowIndex * $ColuIndex Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColuIndex * $RowsCount Local $SizeB = $ColuIndex * $RowsCount;( $ByteSize * ($ColuIndex * $RowsCount) ) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray2D,1,$RowIndex) DllStructSetData($NewCArray2D,2,$ColuIndex) ;-------------------------------------------ReDim--------------------------------------------------------- Local $ElementNu = ($RowIndex * $ColuIndex) DllStructSetData($NewCArray2D,3,$DataType,$ElementNu) DllStructSetData($NewCArray2D,4,$vValue,$ElementNu) $CArray2D = $NewCArray2D Return True Case Else ; $ColuIndex > $ColusCount And $RowIndex > $RowsCount or $ColuIndex > $ColusCount And $RowIndex = $RowsCount ;-------------------------------------------ReDim--------------------------------------------------------- Local $pRowsCount = $RowsCount ,$pColusCount = $ColusCount If $RowIndex > $RowsCount Then $pRowsCount = $RowIndex If $ColuIndex > $ColusCount Then $pColusCount = $ColuIndex Local $ElementsCount = $pRowsCount * $pColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $RowSizeA = $ColusCount * $DoubleSize Local $RowSizeB = $ColusCount ;* $ByteSize Local $RowSizeC = $ColusCount * $DoubleSize Local $RowSizeD = $ColusCount ;* $ByteSize Local $RowSizeE = $pColusCount * $DoubleSize Local $RowSizeF = $pColusCount ;* $ByteSize For $i = 1 To $RowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$RowSizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$RowSizeB) $ElementsPtr += $RowSizeC $DataTypePtr += $RowSizeD $NewElementsPtr += $RowSizeE $NewDataTypePtr += $RowSizeF Next DllStructSetData($NewCArray2D,1,$pRowsCount) DllStructSetData($NewCArray2D,2,$pColusCount) ;-------------------------------------------ReDim--------------------------------------------------------- $ElementNu = ($RowIndex * $pColusCount) - ($pColusCount - $ColuIndex) DllStructSetData($NewCArray2D,3,$DataType,$ElementNu) DllStructSetData($NewCArray2D,4,$vValue,$ElementNu) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func Add2D(ByRef $CArray2D,$RowsCount = 1,$RowsEnd = True,$ColsCount = 0,$ColsEnd = True) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Local $vIndex = 0 Select Case $RowsCount < 0 Or $ColsCount < 0 Or $iRowsCount < 1 Or $iColusCount < 1 Return SetError(1,0,False) Case $ColsCount = 0 And $RowsCount = 0 Return True Case $ColsCount = 0 Local $NewRowsCount = $iRowsCount + $RowsCount Local $ElementsCount = $NewRowsCount * $iColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $iColusCount * $iRowsCount Local $SizeB = $iColusCount * $iRowsCount;( $ByteSize * ($iColusCount * $iRowsCount) ) Local $SizeC = $DoubleSize * $iColusCount * $RowsCount Local $SizeD = $iColusCount * $RowsCount;( $ByteSize * ($iColusCount * $RowsCount) ) Select Case $RowsEnd = True DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) Case $RowsEnd = False DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeD,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) EndSelect DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$iColusCount) $CArray2D = $NewCArray2D Return True Case Else Local $NewRowsCount = $iRowsCount + $RowsCount Local $NewColsCount = $iColusCount + $ColsCount Local $ElementsCount = $NewRowsCount * ($NewColsCount) Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $iColusCount Local $SizeB = $DoubleSize * $NewColsCount Local $SizeC = $DoubleSize * $ColsCount Local $SizeD = $iColusCount;$ByteSize * $iColusCount Local $SizeE = $NewColsCount;$ByteSize * $NewColsCount Local $SizeF = $ColsCount ;$ByteSize * $ColsCount Local $SizeG = $DoubleSize * $NewColsCount * $RowsCount Local $SizeH = $NewColsCount * $RowsCount;$ByteSize * $NewColsCount * $RowsCount Select Case $RowsEnd = True And $ColsEnd = True For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next Case $RowsEnd = True And $ColsEnd = False For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next Case $RowsEnd = False And $ColsEnd = True $NewElementsPtr += $SizeG $NewDataTypePtr += $SizeH For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next Case $RowsEnd = False And $ColsEnd = False $NewElementsPtr += $SizeG $NewDataTypePtr += $SizeH For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next EndSelect DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$NewColsCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func Insert2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Select Case $RowsCount < 0 Or $ColsCount < 0 Or $iRowsCount < 1 Or $iColusCount < 1 Or $RowIndex < 0 _ Or $ColuIndex < 0 Or $RowIndex > ($iRowsCount -1) Or $ColuIndex > ($iColusCount -1) Return SetError(1,0,False) Case $ColsCount = 0 And $RowsCount = 0 Return True Case $ColsCount = 0 Local $NewRowsCount = $iRowsCount + $RowsCount Local $ElementsCount = $NewRowsCount * $iColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $RowIndex * $iColusCount Local $SizeB = $DoubleSize * ($iRowsCount - $RowIndex) * $iColusCount Local $SizeC = $DoubleSize * $RowsCount * $iColusCount + $SizeA Local $SizeD = $RowIndex * $iColusCount;$ByteSize * $RowIndex * $iColusCount Local $SizeE = ($iRowsCount - $RowIndex) * $iColusCount;$ByteSize * ($iRowsCount - $RowIndex) * $iColusCount Local $SizeF = ($RowsCount * $iColusCount) + $SizeD;($ByteSize * $RowsCount * $iColusCount) + $SizeD DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr + $SizeA,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr + $SizeD,"ULONG_PTR",$SizeE) DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$iColusCount) $CArray2D = $NewCArray2D Return True Case Else Local $NewRowsCount = $iRowsCount + $RowsCount Local $NewColsCount = $iColusCount + $ColsCount Local $ElementsCount = $NewRowsCount * $NewColsCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColuIndex Local $SizeB = $DoubleSize * ($iColusCount - $ColuIndex) Local $SizeC = $DoubleSize * $ColsCount Local $SizeD = $DoubleSize * $NewColsCount Local $SizeE = $DoubleSize * $iColusCount Local $SizeF = $DoubleSize * $RowsCount * $NewColsCount Local $SizeG = $ColuIndex;$ByteSize * ColuIndex Local $SizeH = $iColusCount - $ColuIndex;$ByteSize * ($iColusCount - ColuIndex) Local $SizeI = $ColsCount;$ByteSize * $ColsCount Local $SizeJ = $NewColsCount;$ByteSize * $NewColsCount Local $SizeK = $iColusCount;$ByteSize * $iColusCount Local $SizeL = $RowsCount * $NewColsCount;$ByteSize * $RowsCount * $NewColsCount Local $SizeM = $SizeA + $SizeC Local $SizeN = $SizeG + $SizeI For $i = 1 To $RowIndex DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeM,"PTR",$ElementsPtr + $SizeA,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeG) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeN,"PTR",$DataTypePtr + $SizeG,"ULONG_PTR",$SizeH) $NewElementsPtr += $SizeD $ElementsPtr += $SizeE $NewDataTypePtr += $SizeJ $DataTypePtr += $SizeK Next $NewElementsPtr += $SizeF $NewDataTypePtr += $SizeL For $j = $RowIndex + 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeM,"PTR",$ElementsPtr + $SizeA,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeG) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeN,"PTR",$DataTypePtr + $SizeG,"ULONG_PTR",$SizeH) $NewElementsPtr += $SizeD $ElementsPtr += $SizeE $NewDataTypePtr += $SizeJ $DataTypePtr += $SizeK Next DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$NewColsCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func Delete2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Select Case $RowIndex < 0 Or $ColuIndex < 0 Or $RowsCount >= $iRowsCount - $RowIndex _ Or $ColsCount >= $iColusCount - $ColuIndex Or $RowsCount < 0 Or $ColsCount < 0 Return SetError(1,0,False) Case $ColsCount = 0 And $RowsCount = 0 Return True Case $ColsCount = 0 Local $NewRowsCount = $iRowsCount - $RowsCount Local $ElementsCount = $NewRowsCount * $iColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $RowIndex * $iColusCount Local $SizeB = $DoubleSize * ($iRowsCount - ($RowsCount + $RowIndex)) * $iColusCount Local $SizeC = $DoubleSize * $RowsCount * $iColusCount Local $SizeD = $SizeA + $SizeC Local $SizeE = $RowIndex * $iColusCount;$ByteSize * $RowIndex * $iColusCount Local $SizeF = ($iRowsCount - ($RowsCount + $RowIndex)) * $iColusCount;$ByteSize * ($iRowsCount - ($RowsCount + $RowIndex)) * $iColusCount Local $SizeG = $RowsCount * $iColusCount;$ByteSize * $RowsCount * $iColusCount Local $SizeH = $SizeE + $SizeG DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeA,"PTR",$ElementsPtr + $SizeD,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeE,"PTR",$DataTypePtr + $SizeH,"ULONG_PTR",$SizeF) For $i = $RowIndex + 1 To $RowIndex + $RowsCount For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$iColusCount) $CArray2D = $NewCArray2D Case Else $RowIndex += 1 Local $NewColusCount = $iColusCount - $ColsCount Local $NewRowsCount = $iRowsCount - $RowsCount Local $ElementsCount = $NewRowsCount * $NewColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColuIndex Local $SizeB = $DoubleSize * $ColsCount Local $SizeC = $DoubleSize * $iColusCount - ($SizeA + $SizeB) Local $SizeD = $SizeA + $SizeB Local $SizeE = $ColuIndex;$ByteSize * $ColuIndex Local $SizeF = $ColsCount;$ByteSize * $ColsCount Local $SizeG = $iColusCount - ($SizeE + $SizeF);($ByteSize * $iColusCount) - ($SizeE + $SizeF) Local $SizeH = $SizeE + $SizeF Local $SizeI = $DoubleSize * $iColusCount Local $Sizej = $DoubleSize * $NewColusCount Local $SizeK = $iColusCount;$ByteSize * $iColusCount Local $SizeL = $NewColusCount;$ByteSize * $NewColusCount Local $nLoop = $ColuIndex + 1 Local $vLoop = $ColuIndex + $ColsCount Local $vCase = $RowIndex + $RowsCount - 1 For $i = 1 To $iRowsCount Select Case $i < $RowIndex Or $i > $vCase DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeA,"PTR",$ElementsPtr + $SizeD,"ULONG_PTR",$SizeC) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeE,"PTR",$DataTypePtr + $SizeH,"ULONG_PTR",$SizeG) $NewElementsPtr += $Sizej $NewDataTypePtr += $SizeL $ElementsPtr += $SizeI $DataTypePtr += $SizeK For $j = $nLoop To $vLoop $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Case Else $ElementsPtr += $SizeI $DataTypePtr += $SizeK For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next EndSelect Next DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$NewColusCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func FreeCArray2D(ByRef $CArray2D) Local $ElementNu Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") if ($RowsCount = 0 Or $ColusCount = 0) Then Return SetError(1,0,False) ;If DllStructGetData Failure For $i = 1 To $RowsCount For $j = 1 To $ColusCount $ElementNu = ($i * $ColusCount) - ($ColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next $CArray2D = CArray2D($RowsCount,$ColusCount) Return True EndFunc Func DeleteCArray2D(ByRef $CArray2D) Local $ElementNu Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") if ($RowsCount = 0 Or $ColusCount = 0) Then Return SetError(1,0,False) ;If DllStructGetData Failure For $i = 1 To $RowsCount For $j = 1 To $ColusCount $ElementNu = ($i * $ColusCount) - ($ColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next $CArray2D = 0 Return True EndFunc Func Display(ByRef $CArrayStruct,$Title = "DisplayCArray") $TrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") ;Taskbar Window $WPos = WinGetPos($TrayWnd) If Not IsArray($WPos) Then $iH = @DesktopHeight - 68 Else $iH = $WPos[1] - 30 EndIf $RE = DllStructGetData($CArrayStruct,"RE") $CE = DllStructGetData($CArrayStruct,"CE") Local $Error = @error , $Value = "" if $Error Then $CE = 1 $W = (($CE + 1) * 70) + 15 ; $CE + 1 ==> 1 Rows Number $H = (($RE + 1) * 20) + 50 ; $RE + 1 ==> 1 Clos Number If $W > (@DesktopWidth - 5) Then $W = @DesktopWidth - 5 If $H > $iH Then $H = $iH GUICreate($Title,$W,$H,0,0) $W -= 10 $H -= 40 $hListView = GUICtrlCreateListView("",5,5,$W,$H) _GUICtrlListView_SetExtendedListViewStyle($hListView, _ BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_EX_FLATSB)) $CopyButton = GUICtrlCreateButton("Copy Selected", 5,$H + 10, $W - 5, 25) For $i = 0 To $RE - 1 For $j = 0 To $CE - 1 if ($Error) Then $Value = GetAt1D($CArrayStruct,$i) Else $Value = GetAt2D($CArrayStruct,$i,$j) EndIf If $i = 0 Then If $J = 0 Then _ _GUICtrlListView_AddColumn($hListView, "Row",70) _GUICtrlListView_AddColumn($hListView, "Col " & $J,70) EndIf If $j = 0 Then _GUICtrlListView_AddItem($hListView,"",$i) _GUICtrlListView_AddSubItem($hListView,$i, "[" & $i & "]",$j) _GUICtrlListView_AddSubItem($hListView,$i,$Value,$j + 1) Else _GUICtrlListView_AddSubItem($hListView,$i,$Value,$j + 1) EndIf Next Next GUISetState() Do $msg = GUIGetMsg() If $msg = $CopyButton Then $selectionmark = _GUICtrlListView_GetSelectionMark($hListView) ClipPut(_GUICtrlListView_GetItemTextString($hListView,$selectionmark)) EndIf Until $msg = $GUI_EVENT_CLOSE GUIDelete() EndFunc SpeedTest_1D.au3expandcollapse popup#include <Array.au3> #include "CArray.au3" $hTimer1 = TimerInit() Dim $nArray[1] For $i = 1 To 10000 ReDim $nArray[$i] Next $fDiff1 = TimerDiff($hTimer1) $hTimer2 = TimerInit() $vArray1D = CArray1D(1) For $i = 1 To 10000 ReDim1D($vArray1D,$i) Next $fDiff2 = TimerDiff($hTimer2) MsgBox(0,"ReDim Time","Autoit Array ==> " & $fDiff1 & @CRLF & "CArray ==> " & $fDiff2) $hTimer1 = TimerInit() Dim $nArray[1] For $i = 1 To 1000 _ArrayAdd ($nArray,$i) Next $fDiff1 = TimerDiff($hTimer1) $hTimer2 = TimerInit() $vArray1D = CArray1D(1) For $i = 1 To 1000 Add1D($vArray1D,$i) Next $fDiff2 = TimerDiff($hTimer2) MsgBox(0,"Add Time","Autoit Array ==> " & $fDiff1 & @CRLF & "CArray ==> " & $fDiff2) $hTimer1 = TimerInit() Dim $nArray[1000] For $i = 1 To 500 _ArrayDelete($nArray,$i - 1) Next $fDiff1 = TimerDiff($hTimer1) $hTimer2 = TimerInit() $vArray1D = CArray1D(1000) For $i = 1 To 500 DeleteAt1D($vArray1D,$i - 1) Next $fDiff2 = TimerDiff($hTimer2) MsgBox(0,"Delete Time","Autoit Array ==> " & $fDiff1 & @CRLF & "CArray ==> " & $fDiff2) SpeedTest_2D.au3expandcollapse popup#include <Array.au3> #include "CArray.au3" $hTimer1 = TimerInit() Dim $nArray[1][1] , $Max = 0 For $i = 1 To 100 For $j = 1 To 100 if $Max < $j Then ReDim $nArray[$i][$j] $Max += 1 Else ReDim $nArray[$i][$Max] EndIf Next Next $fDiff1 = TimerDiff($hTimer1) $hTimer2 = TimerInit() $Max = 0 $vArray2D = CArray2D(1,1) For $i = 1 To 100 For $j = 1 To 100 if $Max < $j Then ReDim2D($vArray2D,$i,$j) $Max += 1 Else ReDim2D($vArray2D,$i,$Max) EndIf Next Next $fDiff2 = TimerDiff($hTimer2) MsgBox(0,"ReDim Time","Autoit Array ==> " & $fDiff1 & @CRLF & "CArray ==> " & $fDiff2) $hTimer1 = TimerInit() Dim $nArray[1][1] , $Max = 0 For $i = 1 To 50 For $j = 1 To 50 if $Max < $j Then ReDim $nArray[$i][$j] $Max += 1 Else ReDim $nArray[$i][$Max] EndIf $nArray[$i - 1][$j - 1] = $i * $j Next Next $fDiff1 = TimerDiff($hTimer1) $hTimer2 = TimerInit() $vArray2D = CArray2D(1,1) For $i = 1 To 50 For $j = 1 To 50 SetWithReDim2D($vArray2D,$i - 1,$j - 1,$i * $j) Next Next $fDiff2 = TimerDiff($hTimer2) MsgBox(0,"SetWithReDim2D Time","Autoit Array ==> " & $fDiff1 & @CRLF & "CArray ==> " & $fDiff2) Examples Of 1D Array Add_1D.au3#include "CArray.au3" $vArray1D = CArray1D(5) SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") SetAt1D($vArray1D,3,"3") SetAt1D($vArray1D,4,"4") Display($vArray1D) $Rt = Add1D($vArray1D,"beginning",False) ;Add1D(ByRef $CArray1D,$vValue,$End = True) ;Add Value ==> beginning In The beginning // End ==> False $Rt = Add1D($vArray1D,"End") ;Add1D(ByRef $CArray1D,$vValue,$End = True) ;Add Value ==> End In The End // Default End ==> True Display($vArray1D,"Add") DeleteCArray1D($vArray1D) DeleteAt_1D.au3#include "CArray.au3" $vArray1D = CArray1D(6) SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") SetAt1D($vArray1D,3,"3") SetAt1D($vArray1D,4,"4") SetAt1D($vArray1D,5,"5") Display($vArray1D) $Rt = DeleteAt1D($vArray1D,4) ;DeleteAt1D(ByRef $CArray1D,$RowIndex) ;Delete The RowIndex 4 //RowIndex ==> 4 Display($vArray1D,"Delete The RowIndex 4") DeleteCArray1D($vArray1D) DeleteCArray1D.au3#include "CArray.au3" $vArray1D = CArray1D(6) SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") SetAt1D($vArray1D,3,"3") SetAt1D($vArray1D,4,"4") SetAt1D($vArray1D,5,"5") Display($vArray1D) DeleteCArray1D($vArray1D) MsgBox(0,"MSG",$vArray1D) FreeCArray1D.au3#include "CArray.au3" $vArray1D = CArray1D(6) SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") SetAt1D($vArray1D,3,"3") SetAt1D($vArray1D,4,"4") SetAt1D($vArray1D,5,"5") Display($vArray1D) FreeCArray1D($vArray1D) Display($vArray1D) InsertAt_1D.au3#include "CArray.au3" $vArray1D = CArray1D(5) SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") SetAt1D($vArray1D,3,"3") SetAt1D($vArray1D,4,"4") Display($vArray1D) $Rt = InsertAt1D($vArray1D,2,"NewValue1") ;InsertAt1D(ByRef $CArray1D,$RowIndex,$vValue) ;Insert Value ==> NewValue2 At The RowIndex 2 Display($vArray1D) $Rt = InsertAt1D($vArray1D,4,"NewValue2") ;InsertAt1D(ByRef $CArray1D,$RowIndex,$vValue) ;Insert Value ==> NewValue2 At The RowIndex 4 Display($vArray1D) DeleteCArray1D($vArray1D) SetGet1D.au3expandcollapse popup#include "CArray.au3" $iArray1D = CArray1D(3) ; 3 ==> Rows Count For $i = 0 To 3 ; 0 To 3 ==> Over the Count of Rows $Rt = SetAt1D($iArray1D,$i,$i) if (@error Or $Rt = False) Then ; Test Errors MsgBox(0,"BOOL","false" & @CRLF & "$i ==> " & $i) Else MsgBox(0,"BOOL","true" & @CRLF & "$i ==> " & $i) EndIf ; i ==> Row Index And vValue Next Display($iArray1D) DeleteCArray1D($iArray1D) $vArray1D = CArray1D(3) SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") For $i = 0 To 3 ; 0 To 3 ==> Over the Count of Rows $vValue = GetAt1D($vArray1D,$i) ;GetAt1D(ByRef $CArray1D,$RowIndex) GetAt i ==> Row Index ;Return ==> vValue if (@error <> 0) Then ; Test Errors MsgBox(0,"Error","@error ==> " & @error) Else MsgBox(0,"No Error","$vValue ==> " & $vValue) EndIf Next Display($vArray1D) DeleteCArray1D($vArray1D) $nArray1D = CArray1D(1) ; 1 ==> Rows Count For $i = 0 To 10 ;SetAtGrow1D(ByRef $CArray1D,$RowIndex,$vValue) $Rt = SetWithReDim1D($nArray1D,$i,$i) ; i ==> Row Index And vValue Next Display($nArray1D) DeleteCArray1D($nArray1D) UBoundReDim_1D.au3#include "CArray.au3" $vArray1D = CArray1D(4) ; 4 ==> Rows Count SetAt1D($vArray1D,0,"0") SetAt1D($vArray1D,1,"1") SetAt1D($vArray1D,2,"2") SetAt1D($vArray1D,3,"3") Display($vArray1D) ReDim1D($vArray1D,1); // 1 ==> Rows Count Display($vArray1D) $RowsCount = UBound1D($vArray1D);Get Rows Count MsgBox(0,"UBound","RowsCount = " & $RowsCount,0); DeleteCArray1D($vArray1D) Examples Of 2D Array Add_2D.au3expandcollapse popup#include "CArray.au3" $vArray2D = CArray2D(4,4) SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,0,3,"0|3") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,1,3,"1|3") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") SetAt2D($vArray2D,2,3,"2|3") SetAt2D($vArray2D,3,0,"3|0") SetAt2D($vArray2D,3,1,"3|1") SetAt2D($vArray2D,3,2,"3|2") SetAt2D($vArray2D,3,3,"3|3") Display($vArray2D) $Rt = Add2D($vArray2D,2) ;Add2D(ByRef $CArray2D,$RowsCount = 1,$RowsEnd = True,$ColsCount = 0,$ColsEnd = True) ; Add 2 Rows In The End ; RowsCount = 2 ; RowsEnd ==> Default: true ; ;ColsCount = 0,ColsEnd = true Display($vArray2D) $Rt = Add2D($vArray2D,0,0,2) ;Add2D(ByRef $CArray2D,$RowsCount = 1,$RowsEnd = True,$ColsCount = 0,$ColsEnd = True) ; Add 2 Columns In The End ; ColsCount = 2 ; ColsEnd ==> Default: true ; ;RowsCount = 0,RowsEnd = 0 Display($vArray2D) $Rt = Add2D($vArray2D,2,false,2,false) ;Add2D(ByRef $CArray2D,$RowsCount = 1,$RowsEnd = True,$ColsCount = 0,$ColsEnd = True) ; Add 2 Rows And 2 Columns In The beginning ;RowsCount = 2 ; RowsEnd ==> false ;ColsCount = 2 ; ColsEnd ==> false Display($vArray2D) DeleteCArray2D($vArray2D) Delete_2D.au3expandcollapse popup#include "CArray.au3" $vArray2D = CArray2D(6,6) SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,0,3,"0|3") SetAt2D($vArray2D,0,4,"0|4") SetAt2D($vArray2D,0,5,"0|5") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,1,3,"1|3") SetAt2D($vArray2D,1,4,"1|4") SetAt2D($vArray2D,1,5,"1|5") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") SetAt2D($vArray2D,2,3,"2|3") SetAt2D($vArray2D,2,4,"2|4") SetAt2D($vArray2D,2,5,"2|5") SetAt2D($vArray2D,3,0,"3|0") SetAt2D($vArray2D,3,1,"3|1") SetAt2D($vArray2D,3,2,"3|2") SetAt2D($vArray2D,3,3,"3|3") SetAt2D($vArray2D,3,4,"3|4") SetAt2D($vArray2D,3,5,"3|5") SetAt2D($vArray2D,4,0,"4|0") SetAt2D($vArray2D,4,1,"4|1") SetAt2D($vArray2D,4,2,"4|2") SetAt2D($vArray2D,4,3,"4|3") SetAt2D($vArray2D,4,4,"4|4") SetAt2D($vArray2D,4,5,"4|5") SetAt2D($vArray2D,5,0,"5|0") SetAt2D($vArray2D,5,1,"5|1") SetAt2D($vArray2D,5,2,"5|2") SetAt2D($vArray2D,5,3,"5|3") SetAt2D($vArray2D,5,4,"5|4") SetAt2D($vArray2D,5,5,"5|5") Display($vArray2D) $Rt = Delete2D($vArray2D,1,2) ;Delete2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) ;Delete 2 Rows From The RowIndex 1 ; RowsCount = 2 ; RowIndex ==> 1 ; ;int ColuIndex = 0,int ColsCount = 0 Display($vArray2D) $Rt = Delete2D($vArray2D,0,0,1,2) ;Delete2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) ;Delete 2 Columns From The ColuIndex 1 ; ColsCount = 2 ; ColuIndex ==> 1 ;int RowIndex = 0,int RowsCount = 0 Display($vArray2D) $Rt = Delete2D($vArray2D,1,2,1,2) ;Delete2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) ;Delete 2 Rows And 2 Columns From The RowIndex 1 And From ColuIndex 1 ;RowsCount = 2 ; RowIndex ==> 1 ;ColsCount = 2 ; ColuIndex ==> 1 Display($vArray2D) DeleteCArray2D($vArray2D) DeleteCArray2D.au3expandcollapse popup#include "CArray.au3" $vArray2D = CArray2D(6,6) SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,0,3,"0|3") SetAt2D($vArray2D,0,4,"0|4") SetAt2D($vArray2D,0,5,"0|5") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,1,3,"1|3") SetAt2D($vArray2D,1,4,"1|4") SetAt2D($vArray2D,1,5,"1|5") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") SetAt2D($vArray2D,2,3,"2|3") SetAt2D($vArray2D,2,4,"2|4") SetAt2D($vArray2D,2,5,"2|5") SetAt2D($vArray2D,3,0,"3|0") SetAt2D($vArray2D,3,1,"3|1") SetAt2D($vArray2D,3,2,"3|2") SetAt2D($vArray2D,3,3,"3|3") SetAt2D($vArray2D,3,4,"3|4") SetAt2D($vArray2D,3,5,"3|5") SetAt2D($vArray2D,4,0,"4|0") SetAt2D($vArray2D,4,1,"4|1") SetAt2D($vArray2D,4,2,"4|2") SetAt2D($vArray2D,4,3,"4|3") SetAt2D($vArray2D,4,4,"4|4") SetAt2D($vArray2D,4,5,"4|5") SetAt2D($vArray2D,5,0,"5|0") SetAt2D($vArray2D,5,1,"5|1") SetAt2D($vArray2D,5,2,"5|2") SetAt2D($vArray2D,5,3,"5|3") SetAt2D($vArray2D,5,4,"5|4") SetAt2D($vArray2D,5,5,"5|5") Display($vArray2D) DeleteCArray2D($vArray2D) MsgBox(0,"MSG",$vArray2D) FreeCArray2D.au3expandcollapse popup#include "CArray.au3" $vArray2D = CArray2D(6,6) SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,0,3,"0|3") SetAt2D($vArray2D,0,4,"0|4") SetAt2D($vArray2D,0,5,"0|5") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,1,3,"1|3") SetAt2D($vArray2D,1,4,"1|4") SetAt2D($vArray2D,1,5,"1|5") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") SetAt2D($vArray2D,2,3,"2|3") SetAt2D($vArray2D,2,4,"2|4") SetAt2D($vArray2D,2,5,"2|5") SetAt2D($vArray2D,3,0,"3|0") SetAt2D($vArray2D,3,1,"3|1") SetAt2D($vArray2D,3,2,"3|2") SetAt2D($vArray2D,3,3,"3|3") SetAt2D($vArray2D,3,4,"3|4") SetAt2D($vArray2D,3,5,"3|5") SetAt2D($vArray2D,4,0,"4|0") SetAt2D($vArray2D,4,1,"4|1") SetAt2D($vArray2D,4,2,"4|2") SetAt2D($vArray2D,4,3,"4|3") SetAt2D($vArray2D,4,4,"4|4") SetAt2D($vArray2D,4,5,"4|5") SetAt2D($vArray2D,5,0,"5|0") SetAt2D($vArray2D,5,1,"5|1") SetAt2D($vArray2D,5,2,"5|2") SetAt2D($vArray2D,5,3,"5|3") SetAt2D($vArray2D,5,4,"5|4") SetAt2D($vArray2D,5,5,"5|5") Display($vArray2D) FreeCArray2D($vArray2D) Display($vArray2D) Insert_2D.au3expandcollapse popup#include "CArray.au3" $vArray2D = CArray2D(4,4) SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,0,3,"0|3") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,1,3,"1|3") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") SetAt2D($vArray2D,2,3,"2|3") SetAt2D($vArray2D,3,0,"3|0") SetAt2D($vArray2D,3,1,"3|1") SetAt2D($vArray2D,3,2,"3|2") SetAt2D($vArray2D,3,3,"3|3") Display($vArray2D) $Rt = Insert2D($vArray2D,1,2) ;Insert2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) ;Insert 2 Rows From The RowIndex 1 ; RowsCount = 2 ; RowIndex ==> 1 ; ;int ColuIndex = 0,int ColsCount = 0 Display($vArray2D) $Rt = Insert2D($vArray2D,0,0,1,2) ;Insert2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) ;Insert 2 Columns From The ColuIndex 1 ; ColsCount = 2 ; ColuIndex ==> 1 ;int RowIndex = 0,int RowsCount = 0 Display($vArray2D) $Rt = Insert2D($vArray2D,1,2,1,2) ;Insert2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) ;Insert 2 Rows And 2 Columns From The RowIndex 1 And From The ColuIndex 1 ;RowsCount = 2 ; RowIndex ==> 1 ;ColsCount = 2 ; ColuIndex ==> 1 Display($vArray2D) DeleteCArray2D($vArray2D) SetGet2D.au3expandcollapse popup#include "CArray.au3" $iArray2D = CArray2D(3,3) ; 3 ==> Rows Count ; 3 ==> Column Count For $i = 0 To 2 For $j = 0 To 3 ; 0 To 3 ==> Over the Count of columns $Rt = SetAt2D($iArray2D,$i,$j,($i * $j)) ; SetAt2D($iArray2D,i,j,(i * j)) if ($Rt = false And @error) Then ; Test Errors MsgBox(0,"BOOL","false") Else MsgBox(0,"BOOL","true") EndIf ; i ==> Row Index ; j ==> Column Index ; (i * j) ==> vValue Next Next Display($iArray2D) DeleteCArray2D($iArray2D) $vArray2D = CArray2D(3,3) SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") For $i = 0 To 2 For $j = 0 To 3 ; 0 To 3 ==> Over the Count of columns $vValue = GetAt2D($vArray2D,$i,$j) ;GetAt2D(ByRef $CArray2D,$RowIndex,$ColuIndex); i ==> Row Index ; j ==> Column Index ;Return ==> vValue if (@error) Then ; Test Errors MsgBox(0,"@error",@error) Else MsgBox(0,"No Error",$vValue) EndIf Next Next Display($vArray2D) DeleteCArray2D($vArray2D) $nArray2D = CArray2D(1,1) ; 1 ==> Rows Count ; 1 ==> Column Count For $i = 0 To 9 For $j = 0 To 5 $Rt = SetWithReDim2D($nArray2D,$i,$j,($i * $j)) ; iArray2D(i,j,(i * j)) ;SetWithReDim2D(ByRef $CArray2D,$RowIndex,$ColuIndex,$vValue) ; i ==> Row Index ; j ==> Column Index ; (i * j) ==> vValue Next Next Display($nArray2D) DeleteCArray2D($nArray2D) UBoundReDim_2D.au3expandcollapse popup#include "CArray.au3" $iArray2D = CArray2D(1,4) ; 1 ==> Rows Count ; 4 ==> Column Count Display($iArray2D) ReDim2D($iArray2D,4,4) ; 4 ==> Rows Count ; 4 ==> Columns Count ;ReDim2D(ByRef $CArray2D,$RowsCount,$ColusCount) Display($iArray2D) $RowsCount = UBound2D($iArray2D,1) ; Dimension = 1 ; Get Rows Count $ColsCount = UBound2D($iArray2D,2) ; Dimension = 2 ; Get Columns Count ;UBound2D(ByRef $CArray2D , $Dimension = 1) MsgBox(0,"UBound","$RowsCount = " & $RowsCount & " ; $ColsCount = " & $ColsCount) DeleteCArray2D($iArray2D) $jArray2D = CArray2D(1,5) ; 1 ==> Rows Count ; 5 ==> Column Count Display($jArray2D) ReDim2D($jArray2D,3,5) ; 3 ==> Rows Count ; 5 ==> Columns Count Display($jArray2D) DeleteCArray2D($jArray2D) $nArray2D = CArray2D(5,1) ; 5 ==> Rows Count ; 1 ==> Column Count Display($nArray2D) ReDim2D($nArray2D,5,3) ; 5 ==> Rows Count ; 3 ==> Columns Count Display($nArray2D) DeleteCArray2D($nArray2D) $vArray2D = CArray2D(4,4) ; 4 ==> Rows Count ; 4 ==> Columns Count SetAt2D($vArray2D,0,0,"0|0") SetAt2D($vArray2D,0,1,"0|1") SetAt2D($vArray2D,0,2,"0|2") SetAt2D($vArray2D,0,3,"0|3") SetAt2D($vArray2D,1,0,"1|0") SetAt2D($vArray2D,1,1,"1|1") SetAt2D($vArray2D,1,2,"1|2") SetAt2D($vArray2D,1,3,"1|3") SetAt2D($vArray2D,2,0,"2|0") SetAt2D($vArray2D,2,1,"2|1") SetAt2D($vArray2D,2,2,"2|2") SetAt2D($vArray2D,2,3,"2|3") SetAt2D($vArray2D,3,0,"3|0") SetAt2D($vArray2D,3,1,"3|1") SetAt2D($vArray2D,3,2,"3|2") SetAt2D($vArray2D,3,3,"3|3") Display($vArray2D) ReDim2D($vArray2D,3,2) ; 3 ==> Rows Count ; 2 ==> Columns Count Display($vArray2D) $RowsCount = UBound2D($vArray2D,1) ; Dimension = 1 ; Get Rows Count $ColsCount = UBound2D($vArray2D,2) ; Dimension = 2 ; Get Columns Count MsgBox(0,"UBound","$RowsCount = " & $RowsCount & " ; $ColsCount = " & $ColsCount) DeleteCArray2D($vArray2D) SmOke_N, Danyfirex and mesale0077 3 ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 25, 2014 Moderators Share Posted December 25, 2014 (edited) Very cool wolf! Edit: Okay, now I have a question (or a few, but will only list one for now, need sleep before the kiddos get up). What happens when the $CArray1D (as an example) memory address/space goes out of scope? You're using a local scope upon creation, I see the allocated memory, but I don't see what happens if it isn't used initially (declared and set aside for a while). Edited December 25, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
wolf9228 Posted December 27, 2014 Author Share Posted December 27, 2014 Very cool wolf! Edit: Okay, now I have a question (or a few, but will only list one for now, need sleep before the kiddos get up). What happens when the $CArray1D (as an example) memory address/space goes out of scope? You're using a local scope upon creation, I see the allocated memory, but I don't see what happens if it isn't used initially (declared and set aside for a while).  What happens when the $CArray1D (as an example) memory address/space goes out of scope?   Do you mean the scope of the process memory , I know there is a limit to the process memory, if create a very Large structure The process will fail , but is not right determine the maximum size of the array structure You're using a local scope upon creation, I see the allocated memory, but I don't see what happens if it isn't used initially (declared and set aside for a while).   There is no other solution must create a complete array elements, and what do you think is the solution ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 27, 2014 Moderators Share Posted December 27, 2014 Nothing that wouldn't turn into a management nightmare really. Â I like the *must* part anyway. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
wolf9228 Posted December 29, 2014 Author Share Posted December 29, 2014 Nothing that wouldn't turn into a management nightmare really.  I like the *must* part anyway.  Thank you expandcollapse popup#include <GuiListView.au3> #include <GUIConstantsEx.au3> AutoItSetOption("MustDeclareVars", 1) Global $UNICODE = True ; BOOL $UNICODE Global $BinaryToStruct = True ;BOOL $BinaryToStruct True Fast // $tagStruct = "BYTE Binary[" & $BinaryLen & "]" Global $ByteSize=DllStructGetSize(DllStructCreate("BYTE")),$DoubleSize=DllStructGetSize(DllStructCreate("DOUBLE")) Global $OleAut32 = DllOpen("OleAut32.dll") , $Msvcrt = DllOpen("msvcrt.dll") , $kernel32 = DllOpen("kernel32.dll") Func CArray1D($RowsCount) If $RowsCount < 1 Then Return SetError(1,0,0) Local $CArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowsCount & "];DOUBLE ELEMENTS[" & $RowsCount & "]") DllStructSetData($CArray1D,1,$RowsCount) Return $CArray1D EndFunc Func UBound1D(ByRef $CArray1D) Local $RE = DllStructGetData($CArray1D,"RE") if ($RE = 0) Then Return SetError(1,0,0) Return $RE EndFunc Func ReDim1D(ByRef $CArray1D,$RowsCount) Local $iRowsCount = DllStructGetData($CArray1D, 1) Local $TestBool = $iRowsCount > 0 And $RowsCount > 0 Select Case $TestBool And $RowsCount > $iRowsCount Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowsCount & "];DOUBLE ELEMENTS[" & $RowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = ($DoubleSize * $iRowsCount) Local $SizeB = $iRowsCount ;($ByteSize * $iRowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$RowsCount) $CArray1D = $NewCArray1D Return True Case $TestBool And $RowsCount < $iRowsCount Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowsCount & "];DOUBLE ELEMENTS[" & $RowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowsCount Local $SizeB = $RowsCount ;($ByteSize * $RowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) For $i = ($RowsCount + 1) To $iRowsCount If (DllStructGetData($CArray1D,2,$i) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$i)) Next DllStructSetData($NewCArray1D,1,$RowsCount) $CArray1D = $NewCArray1D Return True Case ($TestBool) And ($RowsCount = $iRowsCount) Return True EndSelect Return SetError(1,0,False) EndFunc Func GetAt1D(ByRef $CArray1D,$RowIndex) $RowIndex += 1 Local $LPVOID , $String , $BinaryLen Switch DllStructGetData($CArray1D,"DATATYPE",$RowIndex) Case 8 $LPVOID = DllStructGetData($CArray1D,3,$RowIndex) $String = DllCall($Msvcrt,"WSTR:CDECL","wcscpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case 7 $LPVOID = DllStructGetData($CArray1D,3,$RowIndex) $String = DllCall($Msvcrt , "STR:CDECL" ,"strcpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case 6 $LPVOID = DllStructGetData($CArray1D,3,$RowIndex) $BinaryLen = DllCall($OleAut32,"UINT","SysStringByteLen","PTR",$LPVOID) Switch $BinaryToStruct Case True Return DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID) Case False Return DllStructGetData(DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID),1) EndSwitch Case 5 Return DllStructGetData($CArray1D,3,$RowIndex) Case 4 Return DllStructGetData($CArray1D,3,$RowIndex) Case 3 Return DllStructGetData($CArray1D,3,$RowIndex) <> 0 Case 2 Return Ptr(DllStructGetData($CArray1D,3,$RowIndex)) Case 1 Return Default EndSwitch if @error Then Return SetError(1,0,"") ; error For DllStructGetData($CArray1D,"DATATYPE",$RowIndex) Return "" ; Null Values EndFunc Func SetAt1D(ByRef $CArray1D,$RowIndex,$vValue) $RowIndex += 1 Local $DataType = DllStructGetData($CArray1D,2,$RowIndex) , $LPVOID Select Case IsString($vValue) Switch $UNICODE Case True if DllStructSetData($CArray1D,2,8,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) DllStructSetData($CArray1D,3,$LPVOID[0],$RowIndex) Return True Case False if DllStructSetData($CArray1D,2,7,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) DllStructSetData($CArray1D,3,$LPVOID[0],$RowIndex) Return True EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) if DllStructSetData($CArray1D,2,6,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) DllStructSetData($CArray1D,3,$LPVOID,$RowIndex) Return True Case IsInt($vValue) if DllStructSetData($CArray1D,2,5,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsFloat($vValue) if DllStructSetData($CArray1D,2,4,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsBool($vValue) if DllStructSetData($CArray1D,2,3,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsPtr($vValue) if DllStructSetData($CArray1D,2,2,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case IsKeyword($vValue) ;Default Keyword if DllStructSetData($CArray1D,2,1,$RowIndex) = 0 Then Return SetError(1,0,False) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) Return True EndSelect Return SetError(2,0,False) EndFunc Func SetWithReDim1D(ByRef $CArray1D,$RowIndex,$vValue) $RowIndex += 1 Local $RowsCount = DllStructGetData($CArray1D,"RE"),$DataType = 0 , $LPVOID Select Case $RowsCount = 0 Or $RowIndex < 1; Failure For DllStructGetData($CArray1D,"RE") Or $RowIndex < 1 Return SetError(1,0,False) Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(2,0,False) Case $RowIndex <= $RowsCount if DllStructGetData($CArray1D,2,$RowIndex) > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) DllStructSetData($CArray1D,2,$DataType,$RowIndex) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True Case $RowIndex > $RowsCount ;----------------ReDim--------------------------------- Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $RowIndex & "];DOUBLE ELEMENTS[" & $RowIndex & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowsCount Local $SizeB = $RowsCount;($ByteSize * $RowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$RowIndex) ;----------------ReDim--------------------------------- $CArray1D = $NewCArray1D DllStructSetData($CArray1D,2,$DataType,$RowIndex) DllStructSetData($CArray1D,3,$vValue,$RowIndex) Return True EndSelect EndFunc Func Add1D(ByRef $CArray1D,$vValue,$End = True) Local $iRowsCount = DllStructGetData($CArray1D , 1 ),$LPVOID Local $NRowsCount = $iRowsCount + 1 ,$DataType = 0 Select Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(1,0,False) Case $End = True And $iRowsCount > 0 Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $NRowsCount & "];DOUBLE ELEMENTS[" & $NRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $iRowsCount Local $SizeB = $iRowsCount ;($ByteSize * $iRowsCount) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$NRowsCount) DllStructSetData($NewCArray1D,2,$DataType,$NRowsCount) DllStructSetData($NewCArray1D,3,$vValue,$NRowsCount) $CArray1D = $NewCArray1D Return True Case $End = False And $iRowsCount > 0 Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $NRowsCount & "];DOUBLE ELEMENTS[" & $NRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $iRowsCount Local $SizeB = $iRowsCount ;($ByteSize * $iRowsCount) Local $SizeC = $DoubleSize ;($DoubleSize * 1) Local $SizeD = $ByteSize ;($ByteSize * 1) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeD,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray1D,1,$NRowsCount) DllStructSetData($NewCArray1D,2,$DataType,1) DllStructSetData($NewCArray1D,3,$vValue,1) $CArray1D = $NewCArray1D Return True EndSelect if ($DataType > 5) Then DllCall($OleAut32,"NONE","SysFreeString","PTR",$vValue) Return SetError(2,0,False) EndFunc Func InsertAt1D(ByRef $CArray1D,$RowIndex,$vValue) Local $iRowsCount = DllStructGetData($CArray1D,1),$NRowIndex = ($RowIndex + 1) Local $NRowsCount = $iRowsCount + 1 , $DataType = 0 , $LPVOID Select Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(1,0,False) Case $iRowsCount > 0 And $NRowIndex > 0 And $NRowIndex <= $iRowsCount Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $NRowsCount & "];DOUBLE ELEMENTS[" & $NRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowIndex DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) Local $SizeB = $DoubleSize * $NRowIndex Local $SizeC = $DoubleSize * $RowIndex Local $SizeD = $DoubleSize * ($iRowsCount - $RowIndex) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeB,"PTR",$ElementsPtr + $SizeC,"ULONG_PTR",$SizeD) Local $SizeE = $RowIndex;($ByteSize * ($RowIndex)) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) Local $SizeF = $NRowIndex;($ByteSize * $NRowIndex) Local $SizeG = $RowIndex;($ByteSize * $RowIndex ) Local $SizeH = $iRowsCount - $RowIndex;($ByteSize * ($iRowsCount - $RowIndex)) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr + $SizeG,"ULONG_PTR",$SizeH) DllStructSetData($NewCArray1D,1,$NRowsCount) DllStructSetData($NewCArray1D,2,$DataType,$NRowIndex) DllStructSetData($NewCArray1D,3,$vValue,$NRowIndex) $CArray1D = $NewCArray1D Return True EndSelect if ($DataType > 5) Then DllCall($OleAut32,"NONE","SysFreeString","PTR",$vValue) Return SetError(2,0,False) EndFunc Func DeleteAt1D(ByRef $CArray1D,$RowIndex) Local $iRowsCount = DllStructGetData($CArray1D,1) if $RowIndex < 0 Or $RowIndex > $iRowsCount - 1 _ Or $iRowsCount = 0 Then Return SetError(1,0,False) Local $nRowsCount = $iRowsCount - 1 Local $NewCArray1D = DllStructCreate("INT RE;BYTE DATATYPE[" & $nRowsCount & "];DOUBLE ELEMENTS[" & $nRowsCount & "]") Local $DataTypePtr = DllStructGetPtr( $CArray1D , 2 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray1D,2) Local $ElementsPtr = DllStructGetPtr( $CArray1D , 3 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray1D,3) Local $SizeA = $DoubleSize * $RowIndex DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) Local $SizeB = $DoubleSize * ($iRowsCount - ($RowIndex + 1)) Local $SizeC = $DoubleSize * $RowIndex Local $SizeD = $DoubleSize * ($RowIndex + 1) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr + $SizeD,"ULONG_PTR",$SizeB) Local $SizeE = $RowIndex;($ByteSize * $RowIndex) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) Local $SizeF = $iRowsCount - ($RowIndex + 1);($ByteSize * ($iRowsCount - ($RowIndex + 1))) Local $SizeG = $RowIndex;($ByteSize * $RowIndex) Local $SizeH = $RowIndex + 1;($ByteSize * ($RowIndex - 1)) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeG,"PTR",$DataTypePtr + $SizeH,"ULONG_PTR" ,$SizeF) DllStructSetData($NewCArray1D,1,$nRowsCount) $RowIndex += 1 if (DllStructGetData($CArray1D,2,$RowIndex) > 5) Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$RowIndex)) $CArray1D = $NewCArray1D Return True EndFunc Func FreeCArray1D(ByRef $CArray1D) Local $iRowsCount = DllStructGetData($CArray1D,"RE") if ($iRowsCount = 0) Then Return SetError(1,0,False) ;If Failure For $i = 1 To $iRowsCount If DllStructGetData($CArray1D,2,$i) > 5 Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$i)) Next $CArray1D = CArray1D($iRowsCount) Return True EndFunc Func DeleteCArray1D(ByRef $CArray1D) Local $iRowsCount = DllStructGetData($CArray1D,"RE") if ($iRowsCount = 0) Then Return SetError(1,0,False) ;If Failure For $i = 1 To $iRowsCount If DllStructGetData($CArray1D,2,$i) > 5 Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray1D,3,$i)) Next $CArray1D = 0 Return True EndFunc Func CArray2D($RowsCount,$ColusCount) Select Case $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,0) Case Else Local $ElementsCount = $RowsCount * $ColusCount Local $CArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") DllStructSetData($CArray2D,1,$RowsCount) DllStructSetData($CArray2D,2,$ColusCount) Return $CArray2D EndSelect EndFunc Func UBound2D(ByRef $CArray2D , $Dimension = 1) Local $RE , $CE Switch $Dimension Case 1 $RE = DllStructGetData($CArray2D,"RE") if ($RE = 0) Then Return SetError(1,0,0) Return $RE Case 2 $CE = DllStructGetData($CArray2D,"CE") if ($CE = 0) Then Return SetError(1,0,0) Return $CE Case Else Return SetError(2,0,0) EndSwitch EndFunc Func ReDim2D(ByRef $CArray2D,$RowsCount,$ColusCount) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Select Case $iRowsCount < 1 Or $RowsCount < 1 _ Or $iColusCount < 1 Or $iColusCount < 1 Return SetError(1,0,False) Case $ColusCount = $iColusCount And $RowsCount > $iRowsCount Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColusCount * $iRowsCount Local $SizeB = $ColusCount * $iRowsCount;( $ByteSize * ($ColusCount * $iRowsCount) ) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True Case $ColusCount = $iColusCount And $RowsCount < $iRowsCount Local $ElementsCount = $RowsCount * $ColusCount , $ElementNu Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColusCount * $RowsCount Local $SizeB = $ColusCount * $RowsCount;( $ByteSize * ($ColusCount * $RowsCount) ) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) For $i = $RowsCount + 1 To $iRowsCount For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True Case ($ColusCount > $iColusCount And $RowsCount >= $iRowsCount) Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $RowSizeA = $ColusCount * $DoubleSize Local $RowSizeB = $iColusCount * $DoubleSize Local $RowSizeC = $ColusCount ;* $ByteSize ) Local $RowSizeD = $iColusCount ;* $ByteSize ) For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$RowSizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$RowSizeD) $NewElementsPtr += $RowSizeA $ElementsPtr += $RowSizeB $NewDataTypePtr += $RowSizeC $DataTypePtr += $RowSizeD Next DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True Case $ColusCount = $iColusCount And $RowsCount = $iRowsCount Return True Case Else Local $pRowsCount = $iRowsCount , $pColusCount = $iColusCount If $RowsCount < $iRowsCount Then $pRowsCount = $RowsCount If $ColusCount < $iColusCount Then $pColusCount = $ColusCount Local $ElementsCount = $RowsCount * $ColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $RowSizeA = $ColusCount * $DoubleSize Local $RowSizeB = $iColusCount * $DoubleSize Local $RowSizeC = $pColusCount * $DoubleSize Local $RowSizeD = $ColusCount ;* $ByteSize Local $RowSizeE = $iColusCount ;* $ByteSize Local $RowSizeF = $pColusCount ;* $ByteSize For $i = 1 To $iRowsCount Select Case $i <= $pRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$RowSizeC) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$RowSizeF) $NewElementsPtr += $RowSizeA $ElementsPtr += $RowSizeB $NewDataTypePtr += $RowSizeD $DataTypePtr += $RowSizeE For $j = ($pColusCount + 1) To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Case Else For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next EndSelect Next DllStructSetData($NewCArray2D,1,$RowsCount) DllStructSetData($NewCArray2D,2,$ColusCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func GetAt2D(ByRef $CArray2D,$RowIndex,$ColuIndex) Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") $RowIndex += 1 $ColuIndex += 1 Local $ElementNu = ($RowIndex * $ColusCount) - ($ColusCount - $ColuIndex) Local $DataType = DllStructGetData( $CArray2D , 3 , $ElementNu ) Local $LPVOID , $String , $BinaryLen Select Case $RowIndex < 1 Or $RowIndex > $RowsCount Or $ColuIndex < 1 _ Or $ColuIndex > $ColusCount Or $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,"") Case $DataType = 8 $LPVOID = DllStructGetData($CArray2D,4,$ElementNu) $String = DllCall($Msvcrt,"WSTR:CDECL","wcscpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case $DataType = 7 $LPVOID = DllStructGetData($CArray2D,4,$ElementNu) $String = DllCall($Msvcrt , "STR:CDECL" ,"strcpy","PTR",$LPVOID,"PTR",$LPVOID) Return $String[0] Case $DataType = 6 $LPVOID = DllStructGetData($CArray2D,4,$ElementNu) $BinaryLen = DllCall($OleAut32,"UINT","SysStringByteLen","PTR",$LPVOID) Switch $BinaryToStruct Case True Return DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID) Case False Return DllStructGetData(DllStructCreate("BYTE Binary[" & $BinaryLen[0] & "]",$LPVOID),1) EndSwitch Case $DataType = 5 Return DllStructGetData($CArray2D,4,$ElementNu) Case $DataType = 4 Return DllStructGetData($CArray2D,4,$ElementNu) Case $DataType = 3 Return DllStructGetData($CArray2D,4,$ElementNu) <> 0 Case $DataType = 2 Return Ptr(DllStructGetData($CArray2D,4,$ElementNu)) Case $DataType = 1 Return Default EndSelect Return "" ; Null Values EndFunc Func SetAt2D(ByRef $CArray2D,$RowIndex,$ColuIndex,$vValue) Local $RowsCount = DllStructGetData($CArray2D,1) Local $ColusCount = DllStructGetData($CArray2D,2) Local $LPVOID $RowIndex += 1 $ColuIndex += 1 Local $ElementNu = ($RowIndex * $ColusCount) - ($ColusCount - $ColuIndex) Local $DataType = DllStructGetData($CArray2D,3,$ElementNu) Select Case $RowIndex < 1 Or $RowIndex > $RowsCount Or $ColuIndex < 1 _ Or $ColuIndex > $ColusCount Or $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,False) Case IsString($vValue) Switch $UNICODE Case True if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) DllStructSetData($CArray2D,3,8,$ElementNu) DllStructSetData($CArray2D,4,$LPVOID[0],$ElementNu) Return True Case False if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) DllStructSetData($CArray2D,3,7,$ElementNu) DllStructSetData($CArray2D,4,$LPVOID[0],$ElementNu) Return True EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) DllStructSetData($CArray2D,3,6,$ElementNu) DllStructSetData($CArray2D,4,$LPVOID,$ElementNu) Return True Case IsInt($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,5,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsFloat($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,4,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsBool($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,3,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsPtr($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,2,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case IsKeyword($vValue) if $DataType > 5 Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) ;Default Keyword DllStructSetData($CArray2D,3,1,$ElementNu) Return True EndSelect Return SetError(2,0,False) EndFunc Func SetWithReDim2D(ByRef $CArray2D,$RowIndex,$ColuIndex,$vValue) Local $DataType = 0 , $LPVOID Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") $RowIndex += 1 $ColuIndex += 1 Select Case $RowIndex < 1 Or $ColuIndex < 1 Or $RowsCount < 1 Or $ColusCount < 1 Return SetError(1,0,False) Case IsString($vValue) Switch $UNICODE Case True $LPVOID = DllCall($OleAut32,"PTR","SysAllocString","WSTR",$vValue) $DataType = 8 $vValue = $LPVOID[0] Case False $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","STR",$vValue,"UINT",StringLen($vValue)) $DataType = 7 $vValue = $LPVOID[0] EndSwitch Case IsBinary($vValue) Local $BinaryLen = BinaryLen($vValue) $LPVOID = DllCall($OleAut32,"PTR","SysAllocStringByteLen","PTR",0,"UINT",$BinaryLen) $LPVOID = $LPVOID[0] DllStructSetData(DllStructCreate("BYTE[" & $BinaryLen & "]",$LPVOID),1,$vValue) $DataType = 6 $vValue = $LPVOID Case IsInt($vValue) $DataType = 5 Case IsFloat($vValue) $DataType = 4 Case IsBool($vValue) $DataType = 3 Case IsPtr($vValue) $DataType = 2 Case IsKeyword($vValue) ;Default Keyword $DataType = 1 EndSelect Select Case $DataType = 0 Return SetError(2,0,False) Case $RowIndex <= $RowsCount And $ColuIndex <= $ColusCount Local $ElementNu = ($RowIndex * $ColusCount) - ($ColusCount - $ColuIndex) if (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) DllStructSetData($CArray2D,3,$DataType,$ElementNu) DllStructSetData($CArray2D,4,$vValue,$ElementNu) Return True Case $ColuIndex = $ColusCount And $RowIndex > $RowsCount ;-------------------------------------------ReDim--------------------------------------------------------- Local $ElementsCount = $RowIndex * $ColuIndex Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColuIndex * $RowsCount Local $SizeB = $ColuIndex * $RowsCount;( $ByteSize * ($ColuIndex * $RowsCount) ) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) DllStructSetData($NewCArray2D,1,$RowIndex) DllStructSetData($NewCArray2D,2,$ColuIndex) ;-------------------------------------------ReDim--------------------------------------------------------- Local $ElementNu = ($RowIndex * $ColuIndex) DllStructSetData($NewCArray2D,3,$DataType,$ElementNu) DllStructSetData($NewCArray2D,4,$vValue,$ElementNu) $CArray2D = $NewCArray2D Return True Case Else ; $ColuIndex > $ColusCount And $RowIndex > $RowsCount or $ColuIndex > $ColusCount And $RowIndex = $RowsCount ;-------------------------------------------ReDim--------------------------------------------------------- Local $pRowsCount = $RowsCount ,$pColusCount = $ColusCount If $RowIndex > $RowsCount Then $pRowsCount = $RowIndex If $ColuIndex > $ColusCount Then $pColusCount = $ColuIndex Local $ElementsCount = $pRowsCount * $pColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $RowSizeA = $ColusCount * $DoubleSize Local $RowSizeB = $ColusCount ;* $ByteSize Local $RowSizeC = $ColusCount * $DoubleSize Local $RowSizeD = $ColusCount ;* $ByteSize Local $RowSizeE = $pColusCount * $DoubleSize Local $RowSizeF = $pColusCount ;* $ByteSize For $i = 1 To $RowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$RowSizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$RowSizeB) $ElementsPtr += $RowSizeC $DataTypePtr += $RowSizeD $NewElementsPtr += $RowSizeE $NewDataTypePtr += $RowSizeF Next DllStructSetData($NewCArray2D,1,$pRowsCount) DllStructSetData($NewCArray2D,2,$pColusCount) ;-------------------------------------------ReDim--------------------------------------------------------- $ElementNu = ($RowIndex * $pColusCount) - ($pColusCount - $ColuIndex) DllStructSetData($NewCArray2D,3,$DataType,$ElementNu) DllStructSetData($NewCArray2D,4,$vValue,$ElementNu) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func Add2D(ByRef $CArray2D,$RowsCount = 1,$RowsEnd = True,$ColsCount = 0,$ColsEnd = True) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Local $vIndex = 0 Select Case $RowsCount < 0 Or $ColsCount < 0 Or $iRowsCount < 1 Or $iColusCount < 1 Return SetError(1,0,False) Case $ColsCount = 0 And $RowsCount = 0 Return True Case $ColsCount = 0 Local $NewRowsCount = $iRowsCount + $RowsCount Local $ElementsCount = $NewRowsCount * $iColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $iColusCount * $iRowsCount Local $SizeB = $iColusCount * $iRowsCount;( $ByteSize * ($iColusCount * $iRowsCount) ) Local $SizeC = $DoubleSize * $iColusCount * $RowsCount Local $SizeD = $iColusCount * $RowsCount;( $ByteSize * ($iColusCount * $RowsCount) ) Select Case $RowsEnd = True DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) Case $RowsEnd = False DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeD,"PTR",$DataTypePtr,"ULONG_PTR",$SizeB) EndSelect DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$iColusCount) $CArray2D = $NewCArray2D Return True Case Else Local $NewRowsCount = $iRowsCount + $RowsCount Local $NewColsCount = $iColusCount + $ColsCount Local $ElementsCount = $NewRowsCount * ($NewColsCount) Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $iColusCount Local $SizeB = $DoubleSize * $NewColsCount Local $SizeC = $DoubleSize * $ColsCount Local $SizeD = $iColusCount;$ByteSize * $iColusCount Local $SizeE = $NewColsCount;$ByteSize * $NewColsCount Local $SizeF = $ColsCount ;$ByteSize * $ColsCount Local $SizeG = $DoubleSize * $NewColsCount * $RowsCount Local $SizeH = $NewColsCount * $RowsCount;$ByteSize * $NewColsCount * $RowsCount Select Case $RowsEnd = True And $ColsEnd = True For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next Case $RowsEnd = True And $ColsEnd = False For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next Case $RowsEnd = False And $ColsEnd = True $NewElementsPtr += $SizeG $NewDataTypePtr += $SizeH For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next Case $RowsEnd = False And $ColsEnd = False $NewElementsPtr += $SizeG $NewDataTypePtr += $SizeH For $i = 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) $ElementsPtr += $SizeA $DataTypePtr += $SizeD $NewElementsPtr += $SizeB $NewDataTypePtr += $SizeE Next EndSelect DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$NewColsCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func Insert2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Select Case $RowsCount < 0 Or $ColsCount < 0 Or $iRowsCount < 1 Or $iColusCount < 1 Or $RowIndex < 0 _ Or $ColuIndex < 0 Or $RowIndex > ($iRowsCount -1) Or $ColuIndex > ($iColusCount -1) Return SetError(1,0,False) Case $ColsCount = 0 And $RowsCount = 0 Return True Case $ColsCount = 0 Local $NewRowsCount = $iRowsCount + $RowsCount Local $ElementsCount = $NewRowsCount * $iColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $RowIndex * $iColusCount Local $SizeB = $DoubleSize * ($iRowsCount - $RowIndex) * $iColusCount Local $SizeC = $DoubleSize * $RowsCount * $iColusCount + $SizeA Local $SizeD = $RowIndex * $iColusCount;$ByteSize * $RowIndex * $iColusCount Local $SizeE = ($iRowsCount - $RowIndex) * $iColusCount;$ByteSize * ($iRowsCount - $RowIndex) * $iColusCount Local $SizeF = ($RowsCount * $iColusCount) + $SizeD;($ByteSize * $RowsCount * $iColusCount) + $SizeD DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeC,"PTR",$ElementsPtr + $SizeA,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeD) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeF,"PTR",$DataTypePtr + $SizeD,"ULONG_PTR",$SizeE) DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$iColusCount) $CArray2D = $NewCArray2D Return True Case Else Local $NewRowsCount = $iRowsCount + $RowsCount Local $NewColsCount = $iColusCount + $ColsCount Local $ElementsCount = $NewRowsCount * $NewColsCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColuIndex Local $SizeB = $DoubleSize * ($iColusCount - $ColuIndex) Local $SizeC = $DoubleSize * $ColsCount Local $SizeD = $DoubleSize * $NewColsCount Local $SizeE = $DoubleSize * $iColusCount Local $SizeF = $DoubleSize * $RowsCount * $NewColsCount Local $SizeG = $ColuIndex;$ByteSize * ColuIndex Local $SizeH = $iColusCount - $ColuIndex;$ByteSize * ($iColusCount - ColuIndex) Local $SizeI = $ColsCount;$ByteSize * $ColsCount Local $SizeJ = $NewColsCount;$ByteSize * $NewColsCount Local $SizeK = $iColusCount;$ByteSize * $iColusCount Local $SizeL = $RowsCount * $NewColsCount;$ByteSize * $RowsCount * $NewColsCount Local $SizeM = $SizeA + $SizeC Local $SizeN = $SizeG + $SizeI For $i = 1 To $RowIndex DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeM,"PTR",$ElementsPtr + $SizeA,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeG) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeN,"PTR",$DataTypePtr + $SizeG,"ULONG_PTR",$SizeH) $NewElementsPtr += $SizeD $ElementsPtr += $SizeE $NewDataTypePtr += $SizeJ $DataTypePtr += $SizeK Next $NewElementsPtr += $SizeF $NewDataTypePtr += $SizeL For $j = $RowIndex + 1 To $iRowsCount DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeM,"PTR",$ElementsPtr + $SizeA,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeG) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeN,"PTR",$DataTypePtr + $SizeG,"ULONG_PTR",$SizeH) $NewElementsPtr += $SizeD $ElementsPtr += $SizeE $NewDataTypePtr += $SizeJ $DataTypePtr += $SizeK Next DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$NewColsCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func Delete2D(ByRef $CArray2D,$RowIndex = 0,$RowsCount = 1,$ColuIndex = 0,$ColsCount = 0) Local $iRowsCount = DllStructGetData($CArray2D,"RE") Local $iColusCount= DllStructGetData($CArray2D,"CE") Select Case $RowIndex < 0 Or $ColuIndex < 0 Or $RowsCount >= $iRowsCount - $RowIndex _ Or $ColsCount >= $iColusCount - $ColuIndex Or $RowsCount < 0 Or $ColsCount < 0 Return SetError(1,0,False) Case $ColsCount = 0 And $RowsCount = 0 Return True Case $ColsCount = 0 Local $NewRowsCount = $iRowsCount - $RowsCount , $ElementNu Local $ElementsCount = $NewRowsCount * $iColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $RowIndex * $iColusCount Local $SizeB = $DoubleSize * ($iRowsCount - ($RowsCount + $RowIndex)) * $iColusCount Local $SizeC = $DoubleSize * $RowsCount * $iColusCount Local $SizeD = $SizeA + $SizeC Local $SizeE = $RowIndex * $iColusCount;$ByteSize * $RowIndex * $iColusCount Local $SizeF = ($iRowsCount - ($RowsCount + $RowIndex)) * $iColusCount;$ByteSize * ($iRowsCount - ($RowsCount + $RowIndex)) * $iColusCount Local $SizeG = $RowsCount * $iColusCount;$ByteSize * $RowsCount * $iColusCount Local $SizeH = $SizeE + $SizeG DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeA,"PTR",$ElementsPtr + $SizeD,"ULONG_PTR",$SizeB) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeE,"PTR",$DataTypePtr + $SizeH,"ULONG_PTR",$SizeF) For $i = $RowIndex + 1 To $RowIndex + $RowsCount For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$iColusCount) $CArray2D = $NewCArray2D Case Else $RowIndex += 1 Local $NewColusCount = $iColusCount - $ColsCount Local $NewRowsCount = $iRowsCount - $RowsCount Local $ElementsCount = $NewRowsCount * $NewColusCount Local $NewCArray2D = DllStructCreate("INT RE;INT CE;BYTE DATATYPE["&$ElementsCount&"];DOUBLE ELEMENTS["&$ElementsCount&"]") Local $DataTypePtr = DllStructGetPtr( $CArray2D , 3 ) Local $NewDataTypePtr = DllStructGetPtr($NewCArray2D,3) Local $ElementsPtr = DllStructGetPtr( $CArray2D , 4 ) Local $NewElementsPtr = DllStructGetPtr($NewCArray2D,4) Local $SizeA = $DoubleSize * $ColuIndex Local $SizeB = $DoubleSize * $ColsCount Local $SizeC = $DoubleSize * $iColusCount - ($SizeA + $SizeB) Local $SizeD = $SizeA + $SizeB Local $SizeE = $ColuIndex;$ByteSize * $ColuIndex Local $SizeF = $ColsCount;$ByteSize * $ColsCount Local $SizeG = $iColusCount - ($SizeE + $SizeF);($ByteSize * $iColusCount) - ($SizeE + $SizeF) Local $SizeH = $SizeE + $SizeF Local $SizeI = $DoubleSize * $iColusCount Local $Sizej = $DoubleSize * $NewColusCount Local $SizeK = $iColusCount;$ByteSize * $iColusCount Local $SizeL = $NewColusCount;$ByteSize * $NewColusCount Local $nLoop = $ColuIndex + 1 Local $vLoop = $ColuIndex + $ColsCount Local $vCase = $RowIndex + $RowsCount - 1 For $i = 1 To $iRowsCount Select Case $i < $RowIndex Or $i > $vCase DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr,"PTR",$ElementsPtr,"ULONG_PTR",$SizeA) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewElementsPtr + $SizeA,"PTR",$ElementsPtr + $SizeD,"ULONG_PTR",$SizeC) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr,"PTR",$DataTypePtr,"ULONG_PTR",$SizeE) DllCall($kernel32,"NONE","RtlMoveMemory","PTR",$NewDataTypePtr + $SizeE,"PTR",$DataTypePtr + $SizeH,"ULONG_PTR",$SizeG) $NewElementsPtr += $Sizej $NewDataTypePtr += $SizeL $ElementsPtr += $SizeI $DataTypePtr += $SizeK For $j = $nLoop To $vLoop $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Case Else $ElementsPtr += $SizeI $DataTypePtr += $SizeK For $j = 1 To $iColusCount $ElementNu = ($i * $iColusCount) - ($iColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ;Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next EndSelect Next DllStructSetData($NewCArray2D,1,$NewRowsCount) DllStructSetData($NewCArray2D,2,$NewColusCount) $CArray2D = $NewCArray2D Return True EndSelect EndFunc Func FreeCArray2D(ByRef $CArray2D) Local $ElementNu Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") if ($RowsCount = 0 Or $ColusCount = 0) Then Return SetError(1,0,False) ;If DllStructGetData Failure For $i = 1 To $RowsCount For $j = 1 To $ColusCount $ElementNu = ($i * $ColusCount) - ($ColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next $CArray2D = CArray2D($RowsCount,$ColusCount) Return True EndFunc Func DeleteCArray2D(ByRef $CArray2D) Local $ElementNu Local $RowsCount = DllStructGetData($CArray2D,"RE") Local $ColusCount = DllStructGetData($CArray2D,"CE") if ($RowsCount = 0 Or $ColusCount = 0) Then Return SetError(1,0,False) ;If DllStructGetData Failure For $i = 1 To $RowsCount For $j = 1 To $ColusCount $ElementNu = ($i * $ColusCount) - ($ColusCount - $j) If (DllStructGetData($CArray2D,3,$ElementNu) > 5) Then _ ; Null Value = 0 // 6 and 7 and 8 String Ptr And Binary Ptr DllCall($OleAut32,"NONE","SysFreeString","PTR",DllStructGetData($CArray2D,4,$ElementNu)) Next Next $CArray2D = 0 Return True EndFunc Func Display(ByRef $CArrayStruct,$Title = "DisplayCArray") Local $TrayWnd , $WPos , $iH , $RE , $CE , $Error , $Value Local $W , $H , $hListView,$CopyButton,$msg,$selectionmark $TrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") ;Taskbar Window $WPos = WinGetPos($TrayWnd) If Not IsArray($WPos) Then $iH = @DesktopHeight - 68 Else $iH = $WPos[1] - 30 EndIf $RE = DllStructGetData($CArrayStruct,"RE") $CE = DllStructGetData($CArrayStruct,"CE") $Error = @error $Value = "" if $Error Then $CE = 1 $W = (($CE + 1) * 70) + 15 ; $CE + 1 ==> 1 Rows Number $H = (($RE + 1) * 20) + 50 ; $RE + 1 ==> 1 Clos Number If $W > (@DesktopWidth - 5) Then $W = @DesktopWidth - 5 If $H > $iH Then $H = $iH GUICreate($Title,$W,$H,0,0) $W -= 10 $H -= 40 $hListView = GUICtrlCreateListView("",5,5,$W,$H) _GUICtrlListView_SetExtendedListViewStyle($hListView, _ BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_EX_FLATSB)) $CopyButton = GUICtrlCreateButton("Copy Selected", 5,$H + 10, $W - 5, 25) For $i = 0 To $RE - 1 For $j = 0 To $CE - 1 if ($Error) Then $Value = GetAt1D($CArrayStruct,$i) Else $Value = GetAt2D($CArrayStruct,$i,$j) EndIf If $i = 0 Then If $J = 0 Then _ _GUICtrlListView_AddColumn($hListView, "Row",70) _GUICtrlListView_AddColumn($hListView, "Col " & $J,70) EndIf If $j = 0 Then _GUICtrlListView_AddItem($hListView,"",$i) _GUICtrlListView_AddSubItem($hListView,$i, "[" & $i & "]",$j) _GUICtrlListView_AddSubItem($hListView,$i,$Value,$j + 1) Else _GUICtrlListView_AddSubItem($hListView,$i,$Value,$j + 1) EndIf Next Next GUISetState() Do $msg = GUIGetMsg() If $msg = $CopyButton Then $selectionmark = _GUICtrlListView_GetSelectionMark($hListView) ClipPut(_GUICtrlListView_GetItemTextString($hListView,$selectionmark)) EndIf Until $msg = $GUI_EVENT_CLOSE GUIDelete() EndFunc ØµØ±Ø Ø§Ù„Ø³Ù…Ø§Ø¡ كان هنا  Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now