Jump to content

Help me read a position in a array.


magace
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...