blizzedout Posted February 13, 2007 Posted February 13, 2007 is there a better function than this? it becomes very slow when you have 10,000 lines. Isnt there a way you can just overwrite exactly line #5000
Moderators SmOke_N Posted February 13, 2007 Moderators Posted February 13, 2007 Have an example of how you are using it? How slow it is? How fast you "think" it should be? Any attempts on your behalf of re-writing it? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
The Kandie Man Posted February 13, 2007 Posted February 13, 2007 (edited) Yes FileClose(FileOpen("File.txt",2));this line creates and erases the contents of file.txt $h_file = FileOpen("File.txt",1) For $intcount = 1 To 10000 FileWriteLine ( $h_file, "This is line " & $intcount & " of the file i am writing to.") Next FileClose($h_file) Open the file at the beginning and then close the file at the end. _FileWriteToLine() opens and closes the file each time you use it, i believe. Edited February 13, 2007 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
blizzedout Posted February 13, 2007 Author Posted February 13, 2007 (edited) Im using it to store large amounts of numbers. I use the last 4 digits to decide which line the ID will be added too. $content = FileReadLine($file, $line) $content = $content & " " & $Array[$i] _FileWriteToLine("file.txt", $line, $content, 1) and i use it in a until phrase that will usually repeat 40 times. It takes about 5 seconds. but i think thats because it has to take the whole file each time and count all 10,000 lines. Edited February 13, 2007 by blizzedout
blizzedout Posted February 13, 2007 Author Posted February 13, 2007 if i can get the function to work with a file that is already open and write 40 lines to it while its open i think that would save alot of time.
The Kandie Man Posted February 13, 2007 Posted February 13, 2007 I am having a hard time figuring out what you are trying to do. Can you please post the whole script so that i can take a better look at it? "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
enaiman Posted February 13, 2007 Posted February 13, 2007 FileClose(FileOpen("File.txt",2));this line creates and erases the contents of file.txt Thank you for the tip SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
/dev/null Posted February 13, 2007 Posted February 13, 2007 Im using it to store large amounts of numbers. I use the last 4 digits to decide which line the ID will be added too. $content = FileReadLine($file, $line) $content = $content & " " & $Array[$i] _FileWriteToLine("file.txt", $line, $content, 1) and i use it in a until phrase that will usually repeat 40 times. It takes about 5 seconds. but i think thats because it has to take the whole file each time and count all 10,000 lines. DON'T use _FileWriteToLine for this. Read in the whole file (_FileReadToArray), then replace the 40 lines in the array($file_lines[$line] = $content). At the end write the whole file (_FileWriteFromArray). That should reduce the required amount of time dramatically! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
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