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:


set X to the clipboard

I will get this result:


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

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


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

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

You may try :

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

Another idea:

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.

Simply,


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