Jump to content

[SOLVED] combine Arrays respectively


Recommended Posts

Hi dear friends!, i'm sorry for creating a new thread (a new problem), i have over than 9 lists that i want to combine them to be this (in this example, there are 3 test files):

TEST.png.6ef3c654296a307d4200527624c38fb1.thumb.png.baa22b5dc305653db6836279fbe726c5.png

I've written a little code for splitting main information, but i really confused how to make results as "Output.txt", here is that code:
 

$sRegex_1 = StringRegExp(FileRead("1.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3)
$sRegex_2 = StringRegExp(FileRead("2.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3)
$sRegex_3 = StringRegExp(FileRead("3.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3)

For $i = 0 To UBound($sRegex_1) - 1
    ConsoleWrite($sRegex_1[$i] & @CRLF)
    For $j = 0 To UBound($sRegex_2) - 1
        ConsoleWrite($sRegex_2[$j] & @CRLF)
        For $k = 0 To UBound($sRegex_3) - 1
            ConsoleWrite($sRegex_3[$k] & @CRLF)
        Next
    Next
Next

 

Edited by Colduction
Link to post
Share on other sites

You could have posted sample input files instead of an image, that would have saved time.

Local $s = FileRead("1.txt") & @CRLF & FileRead("2.txt") & @CRLF & FileRead("3.txt")
$s = StringRegExpReplace($s, "==\R", "", 2)
Local $a = StringRegExp($s, "(?:\d+\w+\R){2}[-=]{2}\R?", 3)
_ArraySort($a)
Local $sOut = _ArrayToString($a, "", -1, -1, "")
ConsoleWrite($sOut & @LF)

If you have decimal parts > 9 then use a version of _ArraySort which allows numerical sort. Lots of examples already posted.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
11 hours ago, jchd said:

You could have posted sample input files instead of an image

Here you are:

1.txt

2.txt

3.txt

11 hours ago, jchd said:

If you have decimal parts > 9 then use a version of _ArraySort which allows numerical sort. Lots of examples already posted.

In fact, i didn't show main information because it's private, but totally data forms are as showed examples (important datas are between ==)

Link to post
Share on other sites

Now there is no numeric prefix in the data ... a moving target?

Local $s = FileRead("1.txt") & @CRLF & FileRead("2.txt") & @CRLF & FileRead("3.txt")
$s = StringRegExpReplace($s, "==\R", "", 2)
Local $a = StringRegExp($s, "(?:\w+\R){2}==\R?", 3)
_ArraySort($a)
Local $sOut = _ArrayToString($a, "", -1, -1, "")
ConsoleWrite($sOut & @LF)

Does that fit your bill?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

Please stop posting images, it's very painful to the eye.

Are you sure the files exist in the current working directory?

Because this works for me:

>Running:(3.3.15.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\...\t.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
aa
aa
==
bb
bb
==
bb
bb
==
bb
bb
==
cc
cc
==
+>15:18:23 AutoIt3.exe ended.rc:0
+>15:18:23 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.359

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
10 minutes ago, jchd said:

Please stop posting images, it's very painful to the eye.

Sorry, i just wanted to show you what happend.

10 minutes ago, jchd said:

Are you sure the files exist in the current working directory?

Yes!

10 minutes ago, jchd said:

aa aa == bb bb == bb bb == bb bb == cc cc ==

This is not the result that i want, are you decreased some texts in sample files? the output should be this:

Output.txt

Edited by Colduction
Link to post
Share on other sites
4 hours ago, Colduction said:

are you decreased some texts in sample files?

I copied the sample text files you provided yourself. That is:
1.txt

==
aa
aa
==
aa
aa
==

2.txt
 

==
bb
bb
==
bb
bb
==
bb
bb
==

3.txt
 

==
cc
cc
==

Using the code below, I get:
 

Local $s = FileRead("1.txt") & @CRLF & FileRead("2.txt") & @CRLF & FileRead("3.txt")
Local $a = StringRegExp($s, "==\R(?:\w+\R){2}\R?", 3)
_ArraySort($a)
Local $sOut = _ArrayToString($a, "", -1, -1, "") & "=="
ConsoleWrite($sOut & @LF)


Result:
==
aa
aa
==
aa
aa
==
bb
bb
==
bb
bb
==
bb
bb
==
cc
cc
==

I don't understand why you expect extra entries to get in the way and where the numbers come from.

Can you explain the wanted logic in plain details?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

I post (again) my last code which, given the data in the first post provides you with the result you expect in your last post.

Local $s = FileRead("1.txt") & @CRLF & FileRead("2.txt") & @CRLF & FileRead("3.txt")
Local $a = StringRegExp($s, "==\R(?:\w+\R){2}\R?", 3)
_ArraySort($a)
Local $sOut = _ArrayToString($a, "", -1, -1, "") & "=="
ConsoleWrite($sOut & @LF)

This is my last try to catch the butterfly.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
1 hour ago, Colduction said:

But i should think about arrays overflows, if first array completed and second array not completed, then continue second array.

Which "array overflow"?  You concatenate input files, split the result in an 1D array, sort it then glue entries together to build output.
AutoIt arrays can hold 16 million entries. Do you expect your files to contain more than that?

What does "array completed" means.

Aren't you happy with the result provided by my last code?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
15 hours ago, jchd said:

Which "array overflow"?  You concatenate input files, split the result in an 1D array, sort it then glue entries together to build output.
AutoIt arrays can hold 16 million entries. Do you expect your files to contain more than that?

No, i don't mean that, for example i have an array with 2 row and i have to get data via loop, but in this loop i inserted another array with 3 rows, when first array's loop completed, remains 1 row from second array that will not be showed, this is what I mean by overflow and this is my main problem in this thread! RESPECTIVELY AND PERIODIC.

15 hours ago, jchd said:

Aren't you happy with the result provided by my last code?

Sorry sir, no, but thanks for your reply.
I hope that this problem will be solved :(

Link to post
Share on other sites

Like this ? :

#include <Array.au3>
#include <String.au3>


$one = _StrToArr(FileRead("1.txt"))
$two = _StrToArr(FileRead("2.txt"))
$tre = _StrToArr(FileRead("3.txt"))

$end = False

$max1 = UBound($one) / 2
$max2 = UBound($two) / 2
$max3 = UBound($tre) / 2

$max = $max1
If $max2 > $max Then $max = $max2
If $max2 > $max Then $max = $max3

cw("==")
For $x = 0 To $max

    If $x < $max1 Then
        cw($one[($x * 2)])
        cw($one[($x * 2) + 1])
        cw("==")
    EndIf

    If $x < $max2 Then
        cw($two[($x * 2)])
        cw($two[($x * 2) + 1])
        cw("==")
    EndIf

    If $x < $max3 Then
        cw($tre[($x * 2)])
        cw($tre[($x * 2) + 1])
        cw("==")
    EndIf
Next

Func cw($txt)
    ConsoleWrite($txt & @CRLF)
EndFunc   ;==>cw

Func _StrToArr($s)
    Local $a = _StringBetween($s, @CRLF, @CRLF)
    For $x = UBound($a) - 1 To 0 Step -1
        If $a[$x] = "==" Then _ArrayDelete($a, $x)
    Next
    Return $a
EndFunc   ;==>_StrToArr

 

Link to post
Share on other sites
  • Colduction changed the title to [SOLVED] combine two Arrays respectively

Jeez, I now see what you want.  The first problem is that you never explained yourself clearly, and your first example matches what would result from a sort, once elements are split out.

Another skin for that cat, provided the files have the correct format:

Local $iNbFiles = 3
Local $aFiles[$iNbFiles][3] = [["1.txt"], ["2.txt"], ["3.txt"]]

Local Static $iMax = 0
For $i = 0 To UBound($aFiles) - 1
    $aFiles[$i][1] = StringRegExp(FileRead($aFiles[$i][0]), "==\R(?:.+\R){2}", 3)
    $aFiles[$i][2] = UBound($aFiles[$i][1])
    $iMax = _Max($iMax, UBound($aFiles[$i][1]))
Next

Local $sOut, $a
For $i = 0 To $iMax - 1
    For $j = 0 To UBound($aFiles) - 1
        If $i < $aFiles[$j][2] Then $sOut &= ($aFiles[$j][1])[$i]
    Next
Next
$sOut &= "=="

ConsoleWrite($sOut & @LF)

Next time, please, make the minimum effort to fully and clearly explain what you want.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
13 hours ago, jchd said:

The first problem is that you never explained yourself clearly

Yes, i didn't know how to clearing for you to understand what i want! :sweating:

13 hours ago, jchd said:

Next time, please, make the minimum effort to fully and clearly explain what you want.

Roger that!:D:sweating:
At last, i want to say thanks for giving your time on my project!

Link to post
Share on other sites

Another example for your amusement.

#include <Array.au3>

Local $aFiles[][2] = [["1.txt"], ["2.txt"], ["3.txt"]]
Local $iMNCols = 0 ; Maximum Number of Columns (MNC)
Local $sStr = "" ;   This string will be converted into 2D array.

; Files to abbreviated strings
For $i = 0 To UBound($aFiles) - 1
    $aFiles[$i][1] = StringRegExpReplace(FileRead($aFiles[$i][0]), '(?:=+\R)?(\w+)[^=]+(?:=+\R?)?', "\1|") ; De-construct file format.
    StringReplace($aFiles[$i][1], "|", "|")
    $iExt = @extended ;                                @extended contains number of replacements in StringReplace() function.
    $iMNCols = ($iExt > $iMNCols ? $iExt : $iMNCols) ; Get Maximum Number of Columns
Next

; String to 2D array
For $i = 0 To UBound($aFiles) - 1
    $sStr &= StringTrimRight($aFiles[$i][1], 1) & @CRLF ; StringTrimRight() removes trailing "|" .
Next
Local $aData[0][$iMNCols]
_ArrayAdd($aData, StringStripWS($sStr, 2)) ; Append the three rows into the $aData array with $iMNCols number of columns.
_ArrayTranspose($aData) ; Now array has $iMNCols number of rows, with three columns.
;_ArrayDisplay($aData, "", "", 0, Default, "1.txt|2.txt|3.txt")

; 2D array to file re-constructed string with numbers
Local $sRet = "==" & @CRLF
Local $r = 1 ; Counter
For $j = 0 To UBound($aData) - 1
    For $i = 0 To UBound($aData, 2) - 1
        If $aData[$j][$i] <> "" Then
            $sRet &= $r & $aData[$j][$i] & @CRLF & $r & $aData[$j][$i] & @CRLF & "==" & @CRLF
        EndIf
    Next
    $r += 1 ; Increment $r
Next

ConsoleWrite(StringStripWS($sRet, 2) & @CRLF) ; Parameter flag (2) = strip trailing white spaces (@CRLF).

Used the following files with the resultant output.

1.txt:
==
aa
aa
==
aa
aa
==

2.txt:
==
bb
bb
==
bb
bb
==
bb
bb
==
bb
bb
==
bb
bb
==
bb
bb
==

3.txt:
==
cc
cc
==
cc
cc
==
cc
cc
==
cc
cc
==

OUTPUT.txt:
==
1aa
1aa
==
1bb
1bb
==
1cc
1cc
==
2aa
2aa
==
2bb
2bb
==
2cc
2cc
==
3bb
3bb
==
3cc
3cc
==
4bb
4bb
==
4cc
4cc
==
5bb
5bb
==
6bb
6bb
==

 

Link to post
Share on other sites
  • Colduction changed the title to [SOLVED] combine Arrays respectively

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By EmilyLove
      I have a string containing the full path of an executable and an array of executables without their paths. I am trying to compare the string to the list in the array and if a match is found, remove it from the array. The entry get removed from the array successfully, and after checking its return result, uses it to update the ubound if it succeeded, but it doesn't want to update to the new value. Any ideas what I am doing wrong? It acts like it is read-only.
      #include <Array.au3> #include <File.au3> Local $sApp_Exe = "F:\App\Nextcloud\nextcloud.exe" Local $aWaitForEXEX = [3, "Nextcloud.exe", "nextcloudcmd.exe", "QtWebEngineProcess.exe"] For $h = 1 To $aWaitForEXEX[0] If StringInStr($sApp_Exe, $aWaitForEXEX[$h]) <> 0 Then $iRet = _ArrayDelete($aWaitForEXEX, $h) If $iRet <> -1 Then $aWaitForEXEX[0] = $iRet ;this line doesn't work. $aWaitForEXEX[0] doesn't update and shortly gives Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _ArrayDisplay($aWaitForEXEX) EndIf Next  
    • By vinnyMS
      #Include <Array.au3> #include <Constants.au3> $s = FileRead("2.txt") Local $w = StringRegExp($s, '(?is)(\b\w+\b)(?!.*\b\1\b)', 3) _ArrayColInsert($w, 1) For $i = 0 to UBound($w)-1 StringRegExpReplace($s, '(?i)\b' & $w[$i][0] & '\b', $w[$i][0]) $w[$i][1] = @extended Next _ArraySort($w, 1, 0, 0, 1) _ArrayDisplay($w) i have this script that returns 3 columns  
       
      i need to copy the  Col 0 and Col 1 as text to paste on notepad or excel
      you will have to create a "copy" button if possible
      array.au3 2.txt
    • By DannyJ
      I have a dataset like this, (a strubg)
      Username: User1 Type: Admin RegDate: 1999 Username: User2 Type: User RegDate: 2000 How to make a 2 dimensional array that I can display with _ArrayDisplay?
      This would be a perfect 2D array to represent my data:
      Username           Tpye RegDate User1              Admin 1999 User2              User 2000   If you run this Powershell this powershell command, you can get this dataset that I am talking about:
      Get-LocalUser | Select * With this code you can try it to read into a string:
      #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> ; Just for display in example #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion $sCommand = "powershell.exe Get-LocalUser | Select *" Local $iPid = Run($sCommand, @WorkingDir , @SW_SHOW , $STDOUT_CHILD) ProcessWaitClose($iPid) Local $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput) How can I correctly split $sOutput into a 2D array (with the above mentioned layout) that I can display and I work with?
    • By kovlad
      My solution is to write nested arrays without copying.
      The problem was described hier.
       
      Function:
      #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayNestedSet ; Description ...: Assigns a value to an element of a nested 1D array. ; Syntax ........: _ArrayNestedSet(ByRef $aArray, $vIndex, $vValue) ; Parameters ....: $aArray - an array of arrays. ; $vIndex - an index or 1d-array of indexes; ; a size if $vValue not defined (zero to delete). ; $vValue - a value (create, resize or delete if not defined). ; ; Return values .: on success - 1 ; @extended - nesting level of operation ; on failure - 0 ; @extended - nesting level of error ; @error = 1 - invalid array ; @error = 2 - invalid index ; Author ........: ; Modified ......: kovlad ; Remarks .......: ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/185638-assign-a-value-to-an-array-in-array-element/ ; https://www.autoitscript.com/trac/autoit/ticket/3515?replyto=description ; Example .......: Yes ; =============================================================================================================================== Func _ArrayNestedSet(ByRef $aArray, $vIndex, $vValue = Default) Local $extended = @extended + 1 If IsArray($vIndex) Then If UBound($vIndex, 0) <> 1 Then _ Return SetError(2, $extended) If UBound($vIndex) > 1 Then If UBound($aArray, 0) <> 1 Then _ Return SetError(1, $extended) ; keep index for this array Local $i = $vIndex[0] If $i < 0 Or UBound($aArray) <= $i Then _ Return SetError(2, $extended) ; delete index of this array _ArrayDelete($vIndex, 0) ; recursive function call Local $return = _ArrayNestedSet($aArray[$i], $vIndex, $vValue) If @error Then Return SetError(@error, @extended + 1, 0) Else Return SetExtended(@extended + 1, 1) EndIf Else $vIndex = $vIndex[0] EndIf EndIf If $vValue = Default Then If $vIndex < 0 Then _ Return SetError(2, $extended) If $vIndex = 0 Then ; delete array and free memory $aArray = 0 Return SetExtended($extended, 1) EndIf If UBound($aArray, 0) = 1 Then ; resize array keeping data ReDim $aArray[$vIndex] Return SetExtended($extended, 1) Else ; create new nested array Local $aTmp[$vIndex] $aArray = $aTmp Return SetExtended($extended, 1) EndIf Else If UBound($aArray) <= $vIndex Then _ Return SetError(2, $extended + 1) ; set value of array entry $aArray[$vIndex] = $vValue Return SetExtended($extended, 1) EndIf EndFunc  
      Examples:
      ; write value to 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write value to 1st nested array" & @CRLF) Local $aTmp1[4] = [1,2,3,4] _ArrayDisplay($aTmp1, "$aTmp1") Local $aArray[2] = [$aTmp1] ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 3, 14) = " & _ArrayNestedSet($aArray[0], 3, 14) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay($aArray[0], "$aArray[0]") ; resize 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : resize 1st nested array" & @CRLF) ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 8) = " & _ArrayNestedSet($aArray[0], 8) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay($aArray[0], "$aArray[0]") ; write array to 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write array to 1st nested array" & @CRLF) Local $aTmp11[4] = [11,12,13,14] _ArrayDisplay($aTmp11, "$aTmp11") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 2, $aTmp11) = " & _ArrayNestedSet($aArray[0], 2, $aTmp11) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; write value to 2nd nested array using index array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write value to 2nd nested array using index array" & @CRLF) Local $aIndex1[2] = [2,3] _ArrayDisplay($aIndex1, "$aIndex1") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex1, 140) = " & _ArrayNestedSet($aArray[0], $aIndex1, 140) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; resize 2nd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : resize 2nd nested array" & @CRLF) Local $aIndex1[2] = [2,8] _ArrayDisplay($aIndex1, "$aIndex1") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex1) = " & _ArrayNestedSet($aArray[0], $aIndex1) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; create new 3rd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : create new 3rd nested array" & @CRLF) Local $aIndex2[3] = [2,7,6] _ArrayDisplay($aIndex2, "$aIndex2") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex2) = " & _ArrayNestedSet($aArray[0], $aIndex2) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay((($aArray[0])[2])[7], ")($aArray[0])[2])[7]") ; delete 3rd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : delete 3rd nested array" & @CRLF) Local $aIndex3[3] = [2,7,0] _ArrayDisplay($aIndex3, "$aIndex2") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex3) = " & _ArrayNestedSet($aArray[0], $aIndex3) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray((($aArray[0])[2])[7]) = " & IsArray((($aArray[0])[2])[7]) & @CRLF & @CRLF) ; write 0 in 1st nested array to delete the 2nd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write 0 in 1st nested array to delete the 2nd nested array" & @CRLF) Local $aIndex4[1] = [2] _ArrayDisplay($aIndex4, "$aIndex4") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex4, 0) = " & _ArrayNestedSet($aArray[0], $aIndex4, 0) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray(($aArray[0])[2]) = " & IsArray(($aArray[0])[2]) & @CRLF & @CRLF) ; delete 1st nested array (same as '$aArray[0] = 0') ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : delete 1st nested array (same as '$aArray[0] = 0')" & @CRLF) Local $aIndex5[1] = [0] _ArrayDisplay($aIndex5, "$aIndex5") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex5) = " & _ArrayNestedSet($aArray[0], $aIndex5) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray($aArray[0]) = " & IsArray($aArray[0]) & @CRLF & @CRLF)  
    • By DannyJ
      $sCommands1 = 'powershell.exe Get-ChildItem' $iPid = run($sCommands1   , @WorkingDir , @SW_SHOW , 0x2) $sOutput = ""  While 1     $sOutput &= StdoutRead($iPID)         If @error Then             ExitLoop         EndIf  WEnd ;~ msgbox(0, '' , $sOutput) ConsoleWrite("$sOutput") ConsoleWrite($sOutput) ConsoleWrite(@CRLF) $aOutput = stringsplit($sOutput ,@LF , 2) For $i=0 To  UBound($aOutput) - 1 Step 1     ConsoleWrite($aOutput[$i]) Next The script above reads the whole directory into a one dimensional array, but I need to work with the array, so I need to split the array into multiple dimensions.
      I have already read some forum answers here, and I have already tried these commands:
       
      Are there any way to use the $aOutput variable like in PowerShell:
      PowerShell:
      $a = Get-ChildItem $a.Mode I imagine this in AutoIt  $aOutput
      ConsoleWrite($aOutput[i].Mode) Or if I split this command into 2 dimension like:
      For $i To UBound($aOutput)-1 Step 1 ConsoleWrite($aOutput[$i][1]) ConsoleWrite($aOutput[$i][2]) Next  
×
×
  • Create New...