#!/usr/bin/osascript
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
--Caution!! This Script must be a "Script Bundle" !
on run paramList
set aClass to class of paramList
if paramList = {} or aClass = script then --No parameter or executed with Script Editor
return retMyComment() of me
else --With parameter with osascript command from Terminal
set p1 to (contents of item 1 of paramList)
if p1 is not equal to missing value then
display notification p1
end if
end if
end run
--Return "Description" data within its Script bundle
on retMyComment()
set myPath to (path to me) as string
set docPath to myPath & "Contents:Resources:description.rtfd:TXT.rtf"
set aRes to retTextFromRTF(docPath) of me
return aRes
end retMyComment
on retTextFromRTF(aFile)
set aFilePath to current application's NSString's stringWithString:(POSIX path of aFile)
set aData to current application's NSData's dataWithContentsOfFile:aFilePath options:0 |error|:(missing value)
set theStyledText to current application's NSMutableAttributedString's alloc()'s initWithData:aData options:(missing value) documentAttributes:(null) |error|:(missing value)
if theStyledText is not equal to missing value then
return (theStyledText's |string|()) as string
else
return false --Not RTF file
end if
end retTextFromRTF