Dear Devon-friends,
I’m trying to write a script that will “zap” an rtf file between my two computers. I am finding as I do so that there seems to be no way to move an styled text data via applescript and recreate it on the other machine. The text becomes plain text when I do so. Leaving out the remote machine issue, you can see this as follows. Place the selection in three pane view on an rich text document with some formatting (bold, italic, etc) and then run this script:
tell application "DEVONthink Pro"
set the_sel to selection
set the_item to first item in the_sel
set the_parent to first parent of the_item
set rich_text to rich text of the_item
set the_rec to create record with {name:"test", type:rtf, rich text:rich_text} in the_parent
end tell
It will strip any formatting from the document
I thought maybe this could be worked around by copying the raw data, i.e. something like this:
tell application "DEVONthink Pro"
set the_sel to selection
set the_item to first item in the_sel
set the_parent to first parent of the_item
set the_data to data of the_item
set the_rec to create record with {name:"test", type:rtf, rich text:""} in the_parent
set rich_text to rich text of the_item
set data of the_rec to the_data
end tell
Seems to me like the first one is a bug, and I can report it one the ticket system if that would be useful. Seems to me the second one should work for rtfs just as it does for webarchives, and that too is a bug, though I could imagine viewing that as an unimplemented feature.
For reasons that have been expressed in another thread, it would be nice if one of these methods worked. If the first method worked, and an AS variable could hold the RTF data, then it could be exported to the a file and manipulated elsewhere (through python for example). But if that doesn’t work, it would be soooo nice to still be able to so.
I’m hoping that these are not bugs, but just me not understanding something about applescript’s variable handling. If there is another way to inject the raw data property from one record to another, I’d be grateful to know it. If not, is it possible to implement it (sometime) (soonish)?
cheers,
Erico
I cc-ed this to Wooden Brain, as I thought he might know the answer to this…