Jump to content

Recommended Posts

Posted

Hi, i'd like to ask if someone help me with this. I want to get the position after stringinstr. Like : The file has "Help" in first line and in the second line there's "AutoIt" It'll search "AutoIt" in the file then will take out the position of it as Line 2.
 

Thank you a lot in advance.

  • Moderators
Posted

If you do FileReadToArray in combination with StringinStr you can do this:

#include <File.au3>

Local $aFile = FileReadToArray(@ScriptDir & "\Output.txt")
    For $sLine In $aFile
        If StringInStr($sLine, "<your string>") Then ConsoleWrite("Data found at line " & $sLine & @CRLF)
    Next

"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!

Posted (edited)

#include<file.au3>

; Help
;AutoIt

Global $aFile[0]
_FileReadToArray(@ScriptFullPath , $aFile)

$sSearch = "AutoIt"

for $i = 0 to $aFile[0]
If stringinstr($aFile[$i] , $sSearch) then msgbox(0, '' , "Line " & $i & ":" & @CRLF & $aFile[$i])
Next

same as above, just late.

Edited by boththose

  Reveal hidden contents

Posted

That $i = 0 in boththose's code should be $i = 1.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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