Sign in to follow this  
Followers 0
magace

Help me read a position in a array.

4 posts in this topic

#1 ·  Posted (edited)

Hello I am having a hard time reading a specific position in a array.  I located the position with $iIndex but I cant figure out how to display the line in a message box.

 

When I run it I get "WCC2ECZ98621" was found in the array at position 5393 on column 0

So I need to display column 0 position 5393

 

Thanks in  advance!!

#include <file.au3>
#include <array.au3> ; only for _ArrayDisplay()

$sFile = "\\Teesttterrr-pc\pxe\programs\DYMO\printer\logs\log.txt"

;Read in lines of text into 1D array
Dim $text
If Not _FileReadToArray($sFile, $text) Then
    MsgBox(4096, "Error", " Error reading text file to Array error:" & @error)
    Exit
EndIf
;_ArrayDisplay($text, "Debug: $text")

Local $sSearch = "WCC2ECZ98621"
If @error Then Exit

Local $sColumn ="WCC2ECZ98621"
If @error Then Exit
$sColumn = Int($sColumn)

Local $iIndex = _ArraySearch($text, $sSearch, 0, 0, 0, 1, 1, $sColumn)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.')
Else
    MsgBox($MB_SYSTEMMODAL, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')
    ;display the line of the array located at $iIndex
EndIf

 

Edited by magace

Share this post


Link to post
Share on other sites



thanks!

 

MsgBox($MB_SYSTEMMODAL, "", $text[$iIndex])

Share this post


Link to post
Share on other sites

I would be interested in the layout of your log file. My assumption, seeing you are identifying both a column and an index, is that you were working with a 2d array, something comma-delimited perhaps. But if you're getting the required value with the the code you have above, it is a 1d array. Why, then, the $sColumn variable?


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0