I trying to set a variable to part of a scroll views attributed text, namely the last paragraph, but can't seem to get the nomenclature right.
The script is below, and my last attempt is between the 'say' lines (I never get to 3)..
if canWeDrawNewMessage then
set textStorage to mainMessagesView's textStorage()
tell textStorage to appendAttributedString_(newText)
end if
if lineFeedFlag then set my bypassColorTrapping to false
if lineFeedFlag and my flashTheMessage then
set textStorage to mainMessagesView's textStorage()
set textStorageString to mainMessagesView's |string|() as text
set theTotal to (count of textStorageString) as integer
set theRange to (count of textStorageString's paragraphs) as integer
set theOffset to (count of paragraph theRange of textStorageString) + 1 as integer
try
say 2
set tempStorage to current application's NSMutableAttributedString's alloc's initWithAttributedString_(textStorage's (paragraph theRange))
say 3
on error errmsg
display dialog "Error in tempStorage " & errmsg
end try
repeat 4 times
try
tell current application to beep
set p to 1
try
tell textStorage to replaceCharactersInRange_withString_({theTotal - theOffset, theOffset}, "")
end try
set p to 2
tell mainMessagesView to display()
tell current application to delay 0.4
set p to 3
tell textStorage to appendAttributedString_(tempStorage)
tell mainMessagesView to display()
tell current application to delay 0.7
on error errmsg
display dialog "repeat loop " & errmsg & " " & p
end try
end repeat
end if