Sunblood Posted June 3, 2005 Posted June 3, 2005 What I need to do is search through a HUGE text file and find any line that has "<TYPE>:" in it. I want to add this line to an array, but only if it hasn't been already added. I can't figure out how I can manage an array like that, or search through it. Tips/Advice/Example?
GaryFrost Posted June 3, 2005 Posted June 3, 2005 Starting code: $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Dim $array ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If StringInStr($line, "<TYPE>:") Then $found = 0 For $x = 0 To UBound($array) - 1 If $line == $array[$x] Then $found = 1 ExitLoop EndIf Next If Not $found Then If IsArray($array) Then ReDim $array[UBound($array) + 1] Else Dim $array[1] EndIf $array[UBound($array) - 1] = $line EndIf EndIf WEnd For $x = 0 To UBound($array) - 1 MsgBox(0, "", $array[$x]) Next FileClose($file) Date from test.txt this is a test this is <TYPE>: another test and another and another one this is <TYPE>: another test SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
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