• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting at some Hidden Clipboard Contents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting at some Hidden Clipboard Contents


  • Subject: Re: Getting at some Hidden Clipboard Contents
  • From: kai <email@hidden>
  • Date: Mon, 19 Mar 2007 02:40:06 +0000


On 18 Mar 2007, at 22:55, Bruce Robertson wrote:

Turns out that it is even easier than I thought...


Here is the write/read version. System events is used because this is called
from inside Filemaker so otherwise there is a terminology conflict.



-- start script
-- get data from field and put onto cliboard
set xmlsource to get data cell "XML" of current record
set mypath to ((path to temporary items) as text) & "script.txt"
set pxpath to (posix path of (path to temporary items) ) & "script.txt"


tell application "System Events"
do shell script "echo " & quoted form of xmlsource & " > " & pxpath

set x to (read alias mypath as «class XMSC»)
set the clipboard to x
end tell
-- end script

It wasn't clear to me from your post what form your original data was in, Bruce. Because of the reference to the run script technique, I assumed you were initially trying to convert XMSC data (in text form) to XML text - which much of my previous suggestion sought to address.


However, from your latest message, it seems that you already have the XML text - which, of course, is very much easier to convert.

... but I still wonder about
eliminating the need to read a file. Is there any way to do something like
this:


Get myVariable as «class XMSC»

Because of syntactic and (some) class similarities, it's often assumed that the 'as <className>' parameter of the read command is equivalent to a coercion. However, it really specifies how a file's data should be interpreted - and can perform some conversions that are just not available from regular coercions.


As you've no doubt discovered, if we tried to coerce the text from the variable XMSC_text above to «class XMSC», we'd merely be rewarded with an error number -1700 [errAECoercionFail]: Can't make "<dummy> etc..." into type «class XMSC».

So we still need to execute a write/read conversion routine. Personally, I don't have a problem with using read/write operations. They're usually fast (often much faster than some in-memory manipulations), non-intrusive and - since any temporary files are automatically discarded following a logout/login cycle - pretty clean.

Incidentally, I'd still write data to file using the write command; for a job like this, it's significantly faster than invoking a shell:

----------------------------

set XML_text to "<dummy>
<Script id=\"1\" name=\"Script\" includeInMenu=\"True\" runFullAccess=\"False\">
<Step id=\"6\" name=\"Go to Layout\" enable=\"True\">
<LayoutDestination value=\"OriginalLayout\"/>
</Step>
</Script>
</dummy>
"
set XMSC_path to (path to temporary items as Unicode text) & "XSMC.dat"
set XMSC_ref to open for access file XMSC_path with write permission
set eof XMSC_ref to 0
write XML_text to XMSC_ref
close access XMSC_ref
read file XMSC_path as "XMSC"


----------------------------

--> «data XMSC3C64756D6D793E0A093C5363726970742069643D223122206E616D653D2253637269 70742220696E636C756465496E4D656E753D2254727565222072756E46756C6C41636365 73733D2246616C7365223E0A09093C537465702069643D223622206E616D653D22476F20 746F204C61796F75742220656E61626C653D2254727565223E0A0909093C4C61796F7574 44657374696E6174696F6E2076616C75653D224F726967696E616C4C61796F7574222F3E 0A09093C2F537465703E0A093C2F5363726970743E0A3C2F64756D6D793E0A»

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Getting at some Hidden Clipboard Contents
      • From: Bruce Robertson <email@hidden>
References: 
 >Re: Getting at some Hidden Clipboard Contents (From: Bruce Robertson <email@hidden>)

  • Prev by Date: Re: System Events scripting of Finder window
  • Next by Date: Re: System Events scripting of Finder window
  • Previous by thread: Re: Getting at some Hidden Clipboard Contents
  • Next by thread: Re: Getting at some Hidden Clipboard Contents
  • Index(es):
    • Date
    • Thread