Jump to content

Check file contents BEFORE saving.

Recommended Posts

Hello guys, I'm creating a script that saves information in CSV, so far everything works fine.

But I want that before saving in the same file (append new line), check if the content is repeated.

I left in the attachment an example of the TXT that contains and the TXT to be replaced.

I was able to locate the lines, even replace, but I don't know how to do BEFORE.



Original.txt Replace.txt

Link to comment
Share on other sites

#include <Array.au3>
#include <File.au3>

Local $sFile = "C:\Coisas\TINA\AreaDeTeste\Nova pasta\Original.txt"
Local $aPCs
    _FileReadToArray($sFile, $aPCs)

For $i = 1 To $aPCs[0]

    Local $DelLine = 0
    If StringInStr($aPCs[$i], "Julia") Then  $DelLine = $i

1 hour ago, ad777 said:


if you want to check file content use:FileRead Fuction & IF_Else.

Yes, @ad777after saving I can.
I wanted the routine before, not to save duplicate.
creating the script after saving would be a possibility, but it's a bad and slow development.

Edited by ARPFre
Link to comment
Share on other sites


you mean like this:

#include <Array.au3>
#include <File.au3>

Local $sFile = ".\Original.txt"
FileCopy($sFile, @TempDir & "\Orginal.txt", 1)
Local $Tmp = FileRead(@TempDir & "\Orginal.txt", -1)
While 1
    if $Tmp = FileRead($sFile, -1) Then
        MsgBox(64, 'Content', 'Repeated!')
Func _exit()
    FileDelete(@TempDir & "\Orginal.txt")
EndFunc   ;==>_exit


iam ِAutoit programmer.

best thing in life is to use your Brain to


everything you want.

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

  • Recently Browsing   0 members

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