I'm finding splitting my script into sub-scripts (or whatever they're called) very frustrating.
Reading a .dat file failed until I enclosed the routine in a 'Tell finder' statement, but now I'm trying to match an array in the same routine, and it's failing. Why? It worked when it was in the main body of the script. Has this problem always existed?
Any answers before I lose my hair, please.
on PrintAcrobatClientSettings()
# PITSTOP PRO addition
tell application "Mail"
activate
try
set clientname to sender of currentMailItem2
on error
tell application "Finder"
activate
display dialog "Error in getting mail sender"
return {}
end tell
end try
end tell
set stringToFind to clientname as text
# Parse and shorten names
set o to offset of "<" in stringToFind
set oo to offset of ">" in stringToFind
if (o + 2) < oo and o ≠ 0 and oo ≠ 0 then
set stringToFind to characters (o + 1) thru (oo - 1) of stringToFind as text
else
set ooo to offset of "," in stringToFind
if ooo > 2 then
set stringToFind to characters 1 thru (ooo - 1) of stringToFind as text
end if
end if
--display dialog stringToFind as text
set test to {}
try
tell application "Finder"
set tempPath to MailManagerDesktopFolderPath & ":Acrobat Printing List.dat" as text
set test2 to read file tempPath as list
set theFlag to false
end tell
repeat with theTest in test2
if (stringToFind as text) is in theGraphClient of theTest then
set theFlag to true
my SayTheText("Client matched")
exit repeat
end if
end repeat
set theFavouritesString to ""
if theFlag then
set theFavouritesString to theGraphCount of theTest as text
end if
on error
display dialog "Error in Acrobat Clients"
return {}
end try
return theFavouritesString
end PrintAcrobatClientSettings