Jump to content
Sign in to follow this  
amakrkr

Problem with writing ASCI -> ASCI

Recommended Posts

amakrkr

hello,

i have the following tast to do.

In my case i have two .txt files.

Now i have to make an outomated script that will run non stop checking in Primal.txt for new lines and if it will find them they will be copied to the Copy.txt file.

Here is my script so far....but it doesnt work for some odd reason, maybe someone of you could take a quick look at it?

thx

#include <File.au3>


$file = FileOpen("C:\Users\agg\Desktop\ascii to ascii\Primal.txt", 1)
$file_copy = FileOpen("C:\Users\agg\Desktop\ascii to ascii\Copy.txt", 1)


While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    FileWriteLine($file_copy, $line)
Wend

FileClose($file)
FileClose($file_copy)

Share this post


Link to post
Share on other sites
amakrkr

It's most likely the flags you are using for FileOpen. One should be opened in read mode, and one in write mode.

:) my god so simple ^^

it works great now thx !!

it sohuld be like this:

#include <File.au3>

$file = FileOpen("C:\Users\xxxxx\Desktop\ascii to ascii\Primal.txt", 0)
$file_copy = FileOpen("C:\Users\xxxxx\Desktop\ascii to ascii\Copy.txt", 1)



While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    FileWriteLine($file_copy, $line)
Wend

FileClose($file)
Edited by amakrkr

Share this post


Link to post
Share on other sites
amakrkr

sorry to bother you again.

I just found my next problem....

when i copy from Primal.txt to Copy.txt i dont want to duplicate the records.

For example i would like my program to copy only those lines which are in

Copy.txt.

i hope you understand what i mean.

So far i came up with this:

but it doesnt work for some reason....

#include <File.au3>

$file_check = FileOpen(@ScriptDir & "\Primal.txt", 0)

$file = FileOpen(@ScriptDir & "\Primal.txt", 0)
$file_copy = FileOpen(@ScriptDir & "\Copy.txt", 1)

While 1
    $line = FileReadLine($file_check)
    $line_c =  FileReadLine($file_copy)
    
    if $line = $line_c   Then
        ExitLoop
    EndIf
    
    If @error = -1 Then ExitLoop
    FileWriteLine($file_copy, $line)
Wend

FileClose($file)

Share this post


Link to post
Share on other sites
amakrkr

any suggestions guys?

Share this post


Link to post
Share on other sites
jvanegmond

Please wait 24 hours before bumping your own topic.

Personally, I have no clue what you're trying to do. Not even remotely, so I was hoping maybe someone else would be able to decipher what you were asking.

Edited by Manadar

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  

×