On Jun 19, 2010, at 13:34, Charles Turner wrote:
> On Jun 18, 2010, at 11:11 AM, Christiaan Hofman wrote:
>
>> I don't know py-appscript, but you can get the text for the selection easily
>> using the applescript "get text for" command, I think that becomes
>> get_text_for in py_appscript.
>
> This gets back to my original observation of "defects" in PDFKit
What does this have to do with PDFKit?
>
> I'll say I'm not very confident about what I'm doing here, but if I say:
>
>> tell application "Skim"
>> get text for selection of note 1 of document 1
>> end tell
>
>
> I get the error: "Skim got an error: selection of note 1 of document 1
> doesn’t understand the get text for message."
>
This is a very old and very annoying AppleScript bug in its validation of
statements involving properties. Generally, when you get an error like this,
you should insert an extra "get" command (which should be implicit, but it
isn't) as in 'get text for (get selection of note 1 of document 1)'.
I personally always insert "get" when it's supposed to be implicit.
> This makes sense because (in my case) selection is a list of 15 character
> ranges.
>
That's not the reason. In fact this should be a reason NOT to get this error,
because a list should never need to understand a command, only objects need to
do that.
> If I say:
>
>> get text for item 1 of selection of note 1 of document 1
>
>
> I get back the word "dle2". "dle2" isn't found in the text of my selection.
>
> If I do this for each item individually, all 15 return "dle2".
>
> If I say:
>
>> set theSel to selection of note 1 of document 1
>> repeat with i in theSel
>> get text for i
>> end repeat
>
> I get the error: "Skim got an error: Invalid range."
>
Here you need explicitly include the item in a list as in 'get text for {i}'
(also something that AppleScript should understand but doesn't.) You may also
need to explicitly evaluate some properties using 'get' or 'contents of'.
Due to bugs like these AppleScript is almost impossible to write.
> py-appscript also produces an error on the character range. I'm not able to
> decipher the details, but looking at what it produces for a range suggests
> it's returning two character references instead of a numeric like
> "1102:1147". This is why I converted the returned reference to a string and
> did some regex fiddling to get valid reference in my script.
>
> But as I said, I could be missing something really simple here.
>
> Thanks, Charles
You're missing the intricacies/problems of AppleScript.
Also, the text is some special object that you may need to explicitly coerce to
text, as in '(get text for {i}) as text' (again something AppleScript should be
able to do by itself but often doesn't).
Christiaan
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Skim-app-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-users