Sunday, November 29, 2020

#1 2017-07-21 05:24:19 pm

brian_donovan
Member
Registered: 2003-11-10
Posts: 147

Class data from clipboard

Hi, I am trying to make a script check if the data in the clipboard is the right type, If I create the next script:

Applescript:


set X to the clipboard

I will get this result:

Applescript:


--> {«class XMSS»:«data XMSS3C..........

My question is how can I get the XMSS from this code? I have created the next script:

Applescript:


set X to the clipboard
if X does not contain "«class XMSS»" then
   say "Error 1"
end if

but this does not work sad any ideas will help! thank you!


Filed under: clipboard

Offline

 

#2 2017-07-22 03:05:18 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4575

Re: Class data from clipboard

You may try :

Applescript:

set X to the clipboard

set Y to (clipboard info)
--> {{«class weba», 7645}, {«class RTF », 711}, {«class HTML», 7245}, {«class utf8», 62}, {«class ut16», 122}, {uniform styles, 2496}, {string, 60}, {scrap styles, 282}, {Unicode text, 120}}
if Y as text does not contain "«class XMSS»" then
   say "Error 1"
end if

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) samedi 22 juillet 2017 11:05:01

Offline

 

#3 2017-07-23 02:00:51 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5312

Re: Class data from clipboard

Another idea:

Applescript:

set X to (the clipboard as record) & {«class XMSS»:missing value}
set XMSSData to X's «class XMSS»
if (XMSSData is missing value) then
   say "Error 1"
else
   return XMSSData
end if

The first line ensures that X is a record and that it has a «class XMSS» property. If the clipboard contains a record with a «class XMSS» property, X's «class XMSS» property will have the same value. If not, the value will be the 'missing value' from the concatenated record.


NG

Offline

 

#4 2020-11-19 12:46:36 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1444

Re: Class data from clipboard

Simply,

Applescript:


try
   set XMSSData to the clipboard as «class XMSS»
on error
   set XMSSData to missing value -- The clipboard doesn't contain XMSS data
end try


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)