bartekd Posted November 16, 2009 Share Posted November 16, 2009 (edited) I need some help with a loop statement. I have the last line of a text file, but what I want to find out, going backwards from the end of the text file, and ouput the line number that has a certain text. This is what I have. $All_linecount = _FileCountLines($logfile) Last line of the text file If StringInStr(FileReadLine($logfile, $linecount -1), "50") Then ... part of the if statement. I need to loop this, going backwards from the last line until it finds the string 50. If it does find it, I want there to be a variable that is that line number. Can someone help? For example, this is what is in the text file. I want it to ouput line 10 (sdfg sd 50) dfg 50 assd fg dsdsf sdf re sdfg sdfg sd 50 sdfg dffg wedfsd cd gfd s rtdsg sdfg sd 50 dfg dfg sdfg sdf g sdfg sdfg Edited November 16, 2009 by bartekd Link to comment Share on other sites More sharing options...
Mison Posted November 16, 2009 Share Posted November 16, 2009 $All_linecount = _FileCountLines($logfile) For $i = $All_linecount To 1 Step -1 If StringInStr(FileReadLine($logfile, $i), "50") Then ; your script EndIf Next Not tested. Hi ;) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now