blueron Posted August 9, 2005 Posted August 9, 2005 Hi, i need to write a script that can read the entire contents of a text file after a specific line number. .. Say i need to read the contents after the 12th line to all the way down ..I then need to put hat data into another file. how do i go about it ? anyone ? please help.
Stumpii Posted August 9, 2005 Posted August 9, 2005 Try something like the following untested bit of code: $Openfile = FileOpen("test1.txt", 0) $Savefile = FileOpen("test2.txt", 1) ; Check if file opened for reading OK If $Openfile = -1 Then MsgBox(0, "Error", "Unable to open Openfile .") Exit EndIf ; Check if file opened for writing OK If $Savefile = -1 Then MsgBox(0, "Error", "Unable to open Savefile .") Exit EndIf ; Read in lines of text until the EOF is reached $CurrentLineNumber = 1 While 1 $line = FileReadLine($Openfile) If @error = -1 Then ExitLoop If $CurrentLineNumber >= 12 Then FileWriteLine($Savefile, $line) EndIf $CurrentLineNumber = $CurrentLineNumber + 1 WEnd FileClose($Openfile) FileClose($Savefile) Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.
blueron Posted August 10, 2005 Author Posted August 10, 2005 Hey thanx a lot man .. That worked Thank you very much.
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