An asoc project.
I've been asked to insert a bar code into my list of Clients, so have changed from a text field to an NSTextView
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 has to stay there if something goes wrong, but replaced if everything processes ok.
tell current application's NSFont to set myFont to fontWithName_size_("Cochin", 14)
tell current application's NSColorList to set AppleColors to colorListNamed_("Apple")
set someColor to AppleColors's colorWithKey_("Black")
set attrsDict to current application's NSDictionary's dictionaryWithObjects_forKeys_({myFont,someColor}, {current application's NSFontAttributeName, current application's NSForegroundColorAttributeName})
set theText to "Email is from : " & theSendersFullName & linefeed &"Subject is : " & theSubject&linefeed&"Count of attachments is : " & attachmentCount&linefeed&"Printed at " & (actualDate as text) & " Local time."&linefeed&"Which is " & actualDate - (time to GMT) & " Universal time."&linefeed&"If this remains visible, then this job did not process correctly."&linefeed
tell current application's NSAttributedString to set newText to alloc()'s initWithString_attributes_(theText, attrsDict)
set textStorage to textView's textStorage()
-- append new text
tell textStorage to appendAttributedString_(newText)
set someColor to AppleColors's colorWithKey_("Blue")
set attrsDict to current application's NSDictionary's dictionaryWithObjects_forKeys_({myFont,someColor}, {current application's NSFontAttributeName, current application's NSForegroundColorAttributeName})
set theText to "---------------------------------------------------------------------------------------------------"&linefeed
tell current application's NSAttributedString to set newText to alloc()'s initWithString_attributes_(theText, attrsDict)
set textStorage to textView's textStorage()
-- append new text
tell textStorage to appendAttributedString_(newText)