Sign in to follow this  
Followers 0
blizzedout

_FileWriteToLine

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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?


[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by blizzedout

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 *

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0