INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Searching for differences in text file

Searching for differences in text file

(OP)
I have a ten sentence *.txt file that I want to search and find any differences in the individual sentences. The sentences are sequential. I've coded successfully to find the first mis-matched sentences, but can't work out how to continue searching for other mis-matches. What I want to do is continue the search onward from the first mis-matched line already found. Heres an example of the text file --
Now is the time to come to the aid.
Now is the time to come to the aid.
Now is the <b>slime</b> to come to the aid.
Now is the time to come to the aid.
<b>New</b> is the time to come to the aid.

RE: Searching for differences in text file

Open the text file and establish two pointers at the beginning of the file.  Iterate through the file til eof, moving the pointers as needed.  (It's been a long time since I programmed in BASIC)

CODE


FUNCTION checkLine($line)
  'function to compare $line to $text"
END FUNCTION

$text = "Now is the time to come to the aid"
RecLen = 35
OPEN "file.txt" FOR RANDOM AS #1 LEN = RecLen

curLine = 0
badLines = 0
DO WHILE NOT EOF(#1)
   LINE INPUT #1, $line
   curLine = curLine + 1
   IF checkLine($line, $text) THEN
      badLines = badLine + 1
   END IF
LOOP

CLOSE #1

PRINT "There are ", curLine, " lines total.  ", badLines, " of which are wrong"
-Geates
[/code]

"I hope I can chill and see the change - stop the bleed inside and feel again.  Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 

RE: Searching for differences in text file

Do you want to identify if the lines are different (that's easy) or do you want to print out the actual differences in each set of two lines?


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close