Stuck on a StrReplace?

Started by MW4, January 09, 2018, 04:00:17 PM

Previous topic - Next topic

MW4

I have a text file that I loop through one line at a time
I want to find the word "Contact" and delete everything from "Contact" on in that line
Then I'll write to a different named "fixed" file.

I am stuck thinking about how to handle it, maybe a StrReplace?

Here is some example data pre and post of what I'd like it to be.


Roof Type: N/A Contact
Roof Type: Standard Contact Name: Mike
Sales Type: Flood Contact
Sales Type: Flood Contact Name: Mike
Claim Date: 12/29/2017 8:32 PM CT Contact Fax:
Update Date Contact
Update Date Contact Email: Mike@Mike.com


Look for "Contact" & delete everything from "Contact" on in that line, Leaving this:


Roof Type: N/A
Roof Type: Standard
Sales Type: Flood
Sales Type: Flood
Claim Date: 12/29/2017 8:32 PM CT
Update Date
Update Date

I need a nudge in the right direction.  Thanks!!

MW4

Answered myself :)

      FoundIt = StrIndex(ThisLine, "Contact", 1, @FWDSCAN)
      
      If FoundIt == 0
         
      Else
         ThisLine = strsub(ThisLine, 1,FoundIt - 1)
      endif

td

Another example of my favorite kind of question.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade