Jump to content

Recommended Posts

Posted

If not too huge, this might clean your list for ya.

$filename="ACCOUNTS.txt"
$fullfile=StringReplace(Fileread($filename, FileGetSize($filename)),@lf,"")
$fileline=StringSplit($fullfile,@cr)
$fullfile=@cr&$fullfile

Dim $outfile
$outfile=@cr & $outfile
for $i=1 to $fileline[0]
if stringinstr($outfile,@cr&$fileline[$i])=0 then
$outfile=$outfile & $fileline[$i] & @cr
endif
next
$outfile=StringTrimLeft(StringReplace(StringReplace($outfile,@cr,@crlf),@crlf&@crlf,@crlf),2)
filedelete("accountsclean.txt")
filewriteline("accountsclean.txt",$outfile)

AutoIt3, the MACGYVER Pocket Knife for computers.

Posted (edited)

You never actually rewrite the file after you remove the similar lines.

Perform a FileWrite($filename, $fullfile) after $fullfile=@cr & $fullfile. I don't quite understand what you are trying to achieve with this script, but you will need to write it out sometime to the change file.

*** Matt @ MPCS

<{POST_SNAPBACK}>

really??? because its writing them to the file... it just writes them more than once if the same thing gets copied into the clipboard. why would i need to rewrite the whole file alltogether?

if StringInstr($fullfile,@cr & $bak & @CR) =0 then filewriteline($filename,$bak)

--does this part right here NOT write to the file?? ^^^^^^^

and as for scriptkitty suggestion... why is it neccissary to make a new text file.. cant the old one be checked.. and if string not in there, then write to it?

filedelete("accountsclean.txt")

filewriteline("accountsclean.txt",$outfile)

why make a whole new .txt file? why not just use ACCOUNTS.txt?

and its curious.. why you would delete the entire file, then write a new one. what i am trying to accomplish, is to just read every line in ACCOUNTS.txt and match it against what is currently in the clipboard.

if the clipboard contains any one of the lines already in ACCOUNTS.txt then it will simply skip the write process alltogether, and continue the loop

if not, write to the end of ACCOUNTS.txt

I have learned alot from these posts, but im not getting the exact function that I desire.

I shall look at it some more. of course.. ANY help is appreciated :)

thanks.

~Todd

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted

Yea, I make a different file until it is tested, force of habit.

Since FileWriteLine apends the file, if you ran it twice, it would make duplicates of every line each time you ran it. That is why I delete the file first.

This part was basically just a script to clean up the file, and maybe to show how it could be done.

AutoIt3, the MACGYVER Pocket Knife for computers.

Posted

well, i wanted to check the clipboard against the file.. but this works to.

i just write to the file, and afterwards the script uses that code to clean up the file.

so, in conclusion... its good enough.

THANKS! would have taken me forever by myself

~Todd

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Posted (edited)

when i run the script by itself, it works flawlessly.

when i include it into my script, it creates the file a little strangely

it will put squares (some type of crlf that prints as a character?) at the beginning and ends of the names. when i hit backspace on those squares to delete them, i only have to hit it once and it deletes all of the squares on the END of the name that are touching each other in a row. i have to delete each one at the beginning of the names.

and what is more intruiging, is that it does it for about half of the names in the first part of the file, then it gradually stops. i mean, there is alot of squares on the first names, then as you proress further down the file there are less, until the bottom of the files names.. are "square" free.

can anyone tell me what i might do to correct this?

;CHECK IF CLIPBOARD EMPTY & IF NOT EMPTY CLEAN UP NAME

$bak = ClipGet()

if $bak > "" then

$bak = StringTrimLeft($bak, 4)

$bak = StringReplace($bak, ",", "")

;IF NOTHING IN CLIPBOARD, SLEEP

else

sleep(600000)

endif

;WRITE TO FILE

$filename="ACCOUNTS.txt"

filewriteline($filename,$bak)

;CHECK LIST FOR DUPLICATES AND REWRITE

$fullfile=StringReplace(Fileread($filename, FileGetSize($filename)),@lf,"")

$fileline=StringSplit($fullfile,@cr)

$fullfile=@cr&$fullfile

Dim $outfile

$outfile=@cr & $outfile

for $i=1 to $fileline[0]

if stringinstr($outfile,@cr&$fileline[$i])=0 then

$outfile=$outfile & $fileline[$i] & @cr

endif

next

$outfile=StringTrimLeft(StringReplace(StringReplace($outfile,@cr,@crlf),@crlf&@crlf,@crlf),2)

filedelete("ACCOUNTS.txt")

filewriteline("ACCOUNTS.txt",$outfile)

THANKS

~Todd

EDIT: by the way.. this is not the ENTIRE script, it loops infinately... and at the beginning of the loop, it will clipput("") to erase the clipboard. in case you were wondering about the else statement and how that was implemented.

ALSO.. i see whats going on kind of.. alot of the names are really the same names that are already in the list.. but they are missing their first letter.. and are replaced with "squares" so for some reason, when the file is rewritten, it does not save the file correctly into the array. thats my best guess. but why is it doing this, and how to fix it? lol

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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...