myspacee Posted October 29, 2008 Posted October 29, 2008 hello to all, need help. need to replace a row in my text file : a b c d e f i g h l z z z z z you see a lot of identical row 'z' if use _ReplaceStringInFile function replace all 'z' I know row number in file, is possible to replace that line and no others ? Thank you for help ! m.
Andreik Posted October 29, 2008 Posted October 29, 2008 hello to all, need help. need to replace a row in my text file : a b c d e f i g h l z z z z z you see a lot of identical row 'z' if use _ReplaceStringInFile function replace all 'z' I know row number in file, is possible to replace that line and no others ? Thank you for help ! m. Try this: #Include <File.au3> Func ReplaceInRow($FILE,$ROW,$SEARCH,$REPLACE) $OPEN = FileOpen($FILE,0) $LINE = FileReadLine($OPEN,$ROW) FileClose($OPEN) $NEW_LINE = StringReplace($LINE,$SSTRING,$RSTRING) _FileWriteToLine($FILE,$ROW,$NEW_LINE,1) EndFunc
myspacee Posted October 29, 2008 Author Posted October 29, 2008 hmmm some problems, #Include <File.au3> dim $FILE,$ROW,$SEARCH,$REPLACE,$SSTRING,$RSTRING $FILE = "list.txt" ReplaceInRow($FILE,5,"e","find_find_find_find") Func ReplaceInRow($FILE,$ROW,$SEARCH,$REPLACE) $OPEN = FileOpen($FILE,0) $LINE = FileReadLine($OPEN,$ROW) FileClose($OPEN) $NEW_LINE = StringReplace($LINE,$SSTRING,$RSTRING) _FileWriteToLine($FILE,$ROW,$NEW_LINE,1) EndFunc understand concept but can't able to use...
myspacee Posted October 29, 2008 Author Posted October 29, 2008 solved, learn to use _FileWriteToLine, thankyou, m.
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