Caution: newbie to this forum and to AS.
I am a perl programmer, so my mindset definitely makes it difficult to understand AS. Nonetheless, yesterday I decided to write a small AS to emulate the various text grab services – you know, grab the selection and stick it in TextEdit or grab a selection and stick in Mail, whatever. Except, I want to do this with Palm Desktop, which, being a Carbon app, doesn’t understand services.
I wrote the following script, and the line marked with comment doesnot work.
– grab the current text selection in Safari
tell application “Safari” to set contentsTxt to (do JavaScript “getSelection()” in document 1) as string
– the following line does not work
set titleTxt to text 1 thru 20 of contentsTxt
– interestingly, the above line works if contentsTxt is set to
– something static such as
– set contentsTxt to “some very long string that is going to make the contents of my memo”
– the following works if titleTxt is set to something static such as with
– set titleTxt to “Some title”
– or if contentsTxt is set to something static and then
– set titleTxt to text 1 thru 20 of contentsTxt
– however, since the line above trying to set titleTxt to the
– first 20 chars of contentsTxt fails, the following also fails
tell application “Palm Desktop”
activate
make new memo with properties {title:titleTxt, contents:contentsTxt}
end tell
What am I doing wrong? Perhaps there is a better way to do this, and I would like to know that. However, I would also like to know what I am doing wrong above.
Tia.