• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Finding a location in a text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding a location in a text file


  • Subject: Re: Finding a location in a text file
  • From: kai <email@hidden>
  • Date: Sat, 19 Nov 2005 14:25:36 +0000


On 19 Nov 2005, at 12:50, Jim Brandt wrote:

My problem is counting characters.

In Tex-Edit Plus, I can search for "want", and it will correctly search
for and highlight it as the selection.


tell application "Tex-Edit Plus"
	tell window 1
		search looking for "want"
		set x to line offset of selection

I have now located the line that my desired text is on.

What I can't figure out is how to count the characters on
that line (or from the beginning of the document, either
would work) in order to delete up to that point.

Your idea to count characters from the beginning of the document is a sound one, Jim. (In this particular case, line offset merely adds an unnecessary complication.) You should therefore be able to do the job with something like this (single line - watch for wraps):


----------------

tell application "Tex-Edit Plus" to tell front document to if search looking for "want" then delete (text 1 thru character (character before selection's offset))

----------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Finding a location in a text file
      • From: Michelle Steiner <email@hidden>
References: 
 >Finding a location in a text file (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Finding a location in a text file
  • Next by Date: Re: Producing Unicode-only characters
  • Previous by thread: Re: Finding a location in a text file
  • Next by thread: Re: Finding a location in a text file
  • Index(es):
    • Date
    • Thread