Zefed Posted March 26, 2015 Share Posted March 26, 2015 Hello! at once - sorry for my bad engilshi.. is my hmm.. second language. Ok, i have a problem: I must append to line in txt i.e (google translator ) i have in file: word word word and now i wants append: (word1 form input) word1 word word1 word word1 word I hope it is well described (google translator) Im try add to array but still do not know how to do it at once at once at once at once at once at once Link to comment Share on other sites More sharing options...
jdelaney Posted March 26, 2015 Share Posted March 26, 2015 (edited) how about #include <File.au3> _FileCreate("test.txt") FileWrite("test.txt","word1" & @CRLF & "word1" & @CRLF & "word1" & @CRLF ) Local $a[1] _FileReadToArray("test.txt",$a) For $i = 1 To UBound($a)-1 $a[$i] &= " word" Next _FileWriteFromArray("test.txt",$a,1) ConsoleWrite(FileRead("test.txt") & @CRLF) Edited March 26, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Solution Malkey Posted March 26, 2015 Solution Share Posted March 26, 2015 Using the word "append to line" insinuates hanging something onto the end of the line. Your example shows prepending to the lines. That is, adding to the beginning of each line. So, here is an example of adding "word1 " to the beginning of each line in a file. #include <Array.au3> #include <File.au3> _FileCreate("test.txt") FileWrite("test.txt", "word" & @CRLF & "word" & @CRLF & "word") Local $a[1] _FileReadToArray("test.txt", $a) _ArrayDisplay($a) For $i = 1 To UBound($a) - 1 $a[$i] = "word1 " & $a[$i] ; Prepend "word1 " to each array element. Next _FileWriteFromArray("test.txt", $a, 1) ConsoleWrite(FileRead("test.txt") & @CRLF) Link to comment Share on other sites More sharing options...
jdelaney Posted March 26, 2015 Share Posted March 26, 2015 Whoops, good catch. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
iamtheky Posted March 26, 2015 Share Posted March 26, 2015 or he wants "1 word" appended... ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
SadBunny Posted March 27, 2015 Share Posted March 27, 2015 Don't think so: and now i wants append: (word1 form input) Looks like he means prepending/prefixing "word1 " indeed, as in "word1 <form input>" Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Zefed Posted March 27, 2015 Author Share Posted March 27, 2015 Using the word "append to line" insinuates hanging something onto the end of the line. Your example shows prepending to the lines. That is, adding to the beginning of each line. So, here is an example of adding "word1 " to the beginning of each line in a file. #include <Array.au3> #include <File.au3> _FileCreate("test.txt") FileWrite("test.txt", "word" & @CRLF & "word" & @CRLF & "word") Local $a[1] _FileReadToArray("test.txt", $a) _ArrayDisplay($a) For $i = 1 To UBound($a) - 1 $a[$i] = "word1 " & $a[$i] ; Prepend "word1 " to each array element. Next _FileWriteFromArray("test.txt", $a, 1) ConsoleWrite(FileRead("test.txt") & @CRLF) Dude you are the best! Thenks all! 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