Jump to content

Recommended Posts

Posted (edited)

Hello World!

So I have this code

#include <Array.au3>

Run("C:\Windows\System32\query user>>c:\GTScript\query.txt")

$aFileArray = FileReadToArray("c:\GTScript\query.txt") -1

; NOTE: the first line of the file is in element 0, but that only holds column headers so we start from 1!
For $lineIndex = 1 to UBound($aFileArray)

    ; Let's take every group of non-whitespace characters from the current line and put it in an array:
    $aSplit = StringRegExp($aFileArray[$lineIndex], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH)
    _ArrayDisplay($aSplit, "All elements on line")

    ; We know the format of the file, so we know where the values will be in the array:
    $userName = $aSplit[0]
    $userId = $aSplit[2]

    MsgBox(64, "Info", "Username: " & $userName & @CRLF & "ID: " & $userId)
Next

Do you have an Idea on how to rewrite it so it allways tells me row 2  of a certain user, no matter in which Column of ArrayDisplay he is?

Post examples please, since I am still a rookie!

 

With kind regards

Eddi96

Edited by Eddi96
Corrected code

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...