Jump to content

Recommended Posts

Posted (edited)
$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:

Quote

 

ConsoleWrite(_ArrayToString($aOutput))

_ArrayAdd($aOut , _ArrayToString($aOutput) , 0 , " " @CRLF"|" , 1)

_ArraySpilt

 

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

 

Edited by DannyJ
Posted

in my much acclaimed* post titled: 

there is an example of chopping into 2 dimensional array. Maybe that can be of help ?.

Developer General Discussion, is for AutoIt development as a product, not general help scripting.

*much acclaimed may be an exaggeration from the over imaginative author 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
#include <Array.au3>
_ArrayDisplay(_HowToChopSuey())
Func _HowToChopSuey()
    Local $sCommands1 = 'powershell.exe Get-ChildItem'
    Local $ArrayB, $sOutput = "", $iPid = run($sCommands1   , @WorkingDir , @SW_SHOW , 0x2)

    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then ExitLoop
    WEnd

    $aOutput = stringsplit(StringReplace($sOutput, @CR, "") ,@LF , 2)
    Local $aReturn[UBound($aOutput)][6]

    For $i=0 To UBound($aOutput) - 1 ; Step 1
        ConsoleWrite($i & @TAB & $aOutput[$i] & @CRLF)
        $aReturn[$i][0] = $i ; or not, no clue
        $aReturn[$i][1] = StringMid($aOutput[$i], 1, 7)
        $aReturn[$i][2] = StringMid($aOutput[$i], 14, 11)
        $aReturn[$i][3] = StringMid($aOutput[$i], 26, 11)
        $aReturn[$i][4] = StringMid($aOutput[$i], 36, 14)
        $aReturn[$i][5] = StringMid($aOutput[$i], 51)
    Next
Return $aReturn
EndFunc

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

  • Developers
Posted

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
×
×
  • Create New...