t0ddie Posted September 23, 2006 Share Posted September 23, 2006 (edited) this isnt working... i want to remove all duplicate entries, a lil help? here is test.txt 1111 2222 1111 2222 1111 2222 1111 2222 here is the script. im sure its just ONE LITLE THING i overlooked Dim $a_text = "" $sFile = FileOpen(@ScriptDir & "\test.txt",0) SplashTextOn("checking...","Removing Duplicates. please wait.",200,60,420,320) sleep(1000) $whatthefuck = 0 While 1 $whatthefuck = $whatthefuck + 1 $found = 0 $line = FileReadLine($sFile, $whatthefuck) If @error = -1 Then ExitLoop If IsArray($a_text) Then For $i = 0 To UBound($a_text) - 1 If ($a_text[$i] == $line) Then;==? $found = 1 ExitLoop EndIf Next EndIf If (Not $found) Then If IsArray($a_text) Then ReDim $a_text[UBound($a_text) + 1] Else Dim $a_text[1] EndIf $a_text[UBound($a_text) - 1] = $line EndIf WEnd SplashOff() FileClose($sFile) MsgBox(0,"test","output saved in test.txt") this should leave me with 1111 2222 but it does not. please help? Edited September 23, 2006 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 23, 2006 Developers Share Posted September 23, 2006 (edited) which portion of the code save your result back to the file ? Edited September 23, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
t0ddie Posted September 23, 2006 Author Share Posted September 23, 2006 which portion of the code save your result back to the file ? heh.. i knew it was something small i overlooked. but i cant get it working. i added this, and it seems to do nothing FileClose($sFile) FileDelete($sFile) $sFile = FileOpen(@ScriptDir & "\test.txt",1) FileWrite($sFile,$a_text) FileClose($sFile) Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 23, 2006 Developers Share Posted September 23, 2006 (edited) heh.. i knew it was something small i overlooked. but i cant get it working. i added this, and it seems to do nothing FileClose($sFile) FileDelete($sFile) $sFile = FileOpen(@ScriptDir & "\test.txt",1) FileWrite($sFile,$a_text) FileClose($sFile)Correct... You do not set $a_text anywhere... $A_text is an Array... Edited September 23, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
t0ddie Posted September 23, 2006 Author Share Posted September 23, 2006 (edited) Correct... You do not set $a_text anywhere...$A_text is an Array...first line in the scriptDim $a_text = ""i also see redim in places in the code.. so it should be setting the arrayi just copied and pasted this code from my other script where it runs fine.i dont know why it wont run the same way here...its the exact same code. Edited September 23, 2006 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 23, 2006 Developers Share Posted September 23, 2006 (edited) first line in the script Dim $a_text = "" i also see redim in places in the code.. so it should be setting the array i just copied and pasted this code from my other script where it runs fine. i dont know why it wont run the same way here... its the exact same code.Think you need to do some more reading... $a_text is something totally different than $a_text[0] Do NOT expect $a_text to contain all array values as one big string with @CRLF's ..... YOu will have to loop through the array and write each instance separately to the file ... Edited September 23, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
t0ddie Posted September 23, 2006 Author Share Posted September 23, 2006 how does this look? it works... Dim $a_text = "" $sFile = FileOpen(@ScriptDir & "\test.txt",0) $fuckFile = FileOpen(@ScriptDir & "\test2.txt",1) SplashTextOn("checking...","Removing Duplicate keys. please wait.",200,60,420,320) sleep(1000) $whatthefuck = 0 While 1 $whatthefuck = $whatthefuck + 1 $found = 0 $line = FileReadLine($sFile, $whatthefuck) If @error = -1 Then ExitLoop If IsArray($a_text) Then For $i = 0 To UBound($a_text) - 1 If ($a_text[$i] == $line) Then;==? $found = 1 ExitLoop EndIf Next EndIf If (Not $found) Then If IsArray($a_text) Then ReDim $a_text[UBound($a_text) + 1] Else Dim $a_text[1] EndIf $a_text[UBound($a_text) - 1] = $line FileWrite($fuckFile,$line & @CRLF) EndIf WEnd SplashOff() FileClose($sFile) FileClose($fuckFile) thanks for your comments Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 23, 2006 Developers Share Posted September 23, 2006 how does this look? it works...-snip-thanks for your commentsOther than the childish variable names and the strange indentation of your code you seem to like, there's nothing wrong with the logic at first glace ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now