I’m afraid I’ve struck another problem.
I’m trying to set the characteristics of a range of text that varies from Email to Email.
I think I’ve got the method correct for determining the start and end of the text, but can’t seem to format it into a range.
Snippets of some of my code are below.
Second Main eMailIt error unable to set argument 4 - the AppleScript value <NSAppleEventDescriptor: 'utxt'("{88,0}")> could not be coerced to type {_NSRange=QQ}. number -10000 p = 62.3
-- do regex search for runs of the first ending offset
set p to 34
set firstEndOffSetRegex to current application's NSRegularExpression's regularExpressionWithPattern:("Total Mail items processed+") options:0 |error|:(missing value)
set p to 35
set firstEndOffSetMatches to (firstEndOffSetRegex's matchesInString:anNSString options:0 range:{0, theFullLength}) as list
set p to 36
repeat with i from 1 to count of firstEndOffSetMatches
set theFirstOffSetEndOfRange to location of (item 1 of firstEndOffSetMatches)'s range()
set theFirstOffSetEndOfRange to theFirstOffSetEndOfRange - 3
end repeat
if (count of firstEndOffSetMatches) = 0 then set theFirstOffSetEndOfRange to 0
say (count of firstEndOffSetMatches)
say theFirstOffSetEndOfRange as text
-- do regex search for runs of hour reports
set p to 45
set xx to count of ((my hourCutOff) & " Report" as text)
set p to 46
set hourReportRegex to current application's NSRegularExpression's regularExpressionWithPattern:((my hourCutOff) & " Report+” as text ) options:0 |error|:(missing value)
set p to 47
set hourReportMatches to (hourReportRegex's matchesInString:anNSString options:0 range:{0, theFullLength}) as list
-- make changes to "Daily Report" Report
set p to 62
repeat with i from 1 to count of hourReportMatches
set p to 62.1
# The text string to alter is always the first found
set theRangeStart to location of (item 1 of hourReportMatches)'s range()
set p to 62.2
set theRange to "{" & theRangeStart & "," & theFirstOffSetEndOfRange & "}" as text
set p to 62.3
(anNSMutableAttributedString's addAttribute:(current application's NSFontAttributeName) value:theReportFont range:theRange)
set p to 62.4
(anNSMutableAttributedString's addAttribute:(current application's NSForegroundColorAttributeName) value:theReportColor range:theRange)
end repeat