• 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: help needed getting 2nd last line of text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help needed getting 2nd last line of text


  • Subject: Re: help needed getting 2nd last line of text
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 16 Dec 2012 11:46:05 +1100

Thanks for answering Shane.

I'm in deep water, and rapidly drowning with this.

I tried your suggestion re integer, and corrected my typo, but still no success.

   set textStorage to textView's textStorage()
    -- append new text
    set newTextLength to textStorage's  |length|() as integer
   say 6
    set tempString to linefeed
    set theRange  to textStorage's replaceOccurrencesOfString_withString_options_range_(linefeed,linefeed,0,{0 ,newTextLength-1 }) as integer  #backwardsSearch
    say 7
    say theRange

   

I'd like to use the BackwardsSearch, but I'm unsure of the way it should be used. I found someone using 0 on the net, but don't know if it's correct or not!

Any further advice much appreciated.

Regards

Santa

On 16/12/2012, at 11:25 AM, Shane Stanley <email@hidden> wrote:

On 16/12/2012, at 9:10 AM, Brian Christmas <email@hidden> wrote:

I've tried

 set textStorage to textView's textStorage()
   -- append new text
   set newTextLength to textStorage's  |length|() as integer
   say 6
    set theRange  to textstorage's replaceOccurrencesOfString_withString_options_range_(linefeed,linefeed,0,{0,newTextLength-1})  #backwardsSearch
   say theRange

to try and get the count of linefeeds, but it doesn't work. Any ideas please anyone?

textStorage and textstorage are two different things, although the error may disappear as it gets compiled -- it's hard to know. This is another reason why you should edit your AS code in an external editor rather than directly in Xcode. You probably also need to add "as integer" to coerce the result from an NSNumber to an integer. (And that's not a backwards search, not that it matters.)

--
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >help needed getting 2nd last line of text (From: Brian Christmas <email@hidden>)
 >Re: help needed getting 2nd last line of text (From: Shane Stanley <email@hidden>)
 >Re: help needed getting 2nd last line of text (From: Brian Christmas <email@hidden>)
 >Re: help needed getting 2nd last line of text (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: help needed getting 2nd last line of text
  • Next by Date: Re: help needed getting 2nd last line of text
  • Previous by thread: Re: help needed getting 2nd last line of text
  • Next by thread: Re: help needed getting 2nd last line of text
  • Index(es):
    • Date
    • Thread