Re: help needed getting 2nd last line of text
Re: help needed getting 2nd last line of text
- Subject: Re: help needed getting 2nd last line of text
- From: Shane Stanley <email@hidden>
- Date: Sat, 15 Dec 2012 21:50:55 +1100
On 15/12/2012, at 7:11 PM, Brian Christmas <email@hidden> wrote:
I need to remove and replace the second last line in the field if the mail processes ok, but cant work out how to do it. I can insert the appropriate text ok, but the removal has me stumped.
The line to remove is "If this remains visible, then this job did not process correctly."
To delete some text, you need to know its range. So the easiest way is probably to get the contents of the text view as an NSString, and ask it for the range of the target using, then delete that range:
set allText to textView's |string|() -- gets the full contents as an NSString set theRange to allText's rangeOfString_("If this remains visible, then this job did not process correctly." & linefeed) tell textStorage to deleteCharactersInRange_(theRange)
If you instead want to replace the text, use:
tell textStorage to replaceCharactersInRange_withString_(theRange, "Whatever" & linefeed)
tell current application's NSColorList to set AppleColors to colorListNamed_("Apple") set someColor to AppleColors's colorWithKey_("Black")
For basic colors there are dedicated class methods, like this:
set someColor to current application's NSColor's blackColor()
|
_______________________________________________
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