Jump to content

Problem with writing ASCI -> ASCI


amakrkr
 Share

Recommended Posts

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)
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...