How to make a “type class” of value zero (four bytes of 0)

I need to pass an OSType with four zero bytes to my app. Like

«class XXXX»

But with NUL chars in place of the X chars.

See also: https://stackoverflow.com/questions/55880787

My guess is that it’s not possible/illegal.

It’s possible with ASObjC. Someone one StackOverflow suggested:

use framework "Foundation"
set zeroType to (current application's NSAppleEventDescriptor's descriptorWithTypeCode:0) as any

And that works for my needs.

Now I finally have a script to extract all images from a clipping into new separate image clippings in iClip. Yay!

Thanks for all the help, Shane.

The any class is undefined, and it’s probably not a good idea to use it. You’d be better off using something like this:

use framework "Foundation"
set zeroType to item 1 of ((current application's NSArray's arrayWithObject:(current application's NSAppleEventDescriptor's descriptorWithTypeCode:0)) as list)
1 Like

The SO answer suggested “… as anything”, which got turned into “as any” for me. Can’t make sense of it but will heed your proposal.

BTW, this forum software is most excellent. Also works very well on an iPhone.

CJK on SO suggested this alternative, that seems to work for me as well:

set zeroType to (current application's NSAppleEventDescriptor's descriptorWithTypeCode:0) as type class

Do you approve?

There are potential synonym issues. For example, that compiles to simply as type in Script Debugger.

(The problem with any is that it’s actually defined by Script Debugger, so it won’t compile in Script Editor.)

So if it were me, I’d play safe.

1 Like