Getting text of enumerated properties

G’day all,

Many scriptable applications define enumerations. For example Image Events defines:
“color space” as one of the following enumerated types:

Eight channel/Eight color/Five channel/Five color/Seven channel/RGB/Lab/XYZ/Six channel/CMYK/Six color/Seven color/Named/Gray

I would like to be able to get the text of the enumeration within a applescript, rather than having to have a double list of text items and color space enumerated values, for example the first few values of the list might look like:

set colorMapping to {{color space:Eight channel, colorText:“Eight channel”}, {color space:Eight color, colorText:“Eight color”}, {color space:Five channel, colorText:“Five channel”}, …}

which I would then have to iterate over looking for the color space that I have got to determine the desired text.

Suggestions etc. would be appreciated.

Kevin

Hi,

Maybe you can just coerce it to string. I don’t have Image Events but using QuickTime, something like this:

tell application “QuickTime Player”
(scale of front movie) as string
end tell

gl,

That works thanks,

Can you do it the other way, and convert a string into a enumerated type.

Kevin

Hi,

Yes, you can do this, but I’m not sure if it works for all enumerated types and different applications. Something like this using the ‘run script’ standard addition:

tell application “QuickTime Player”
activate
set the_scale to (run script “double”)
set scale of front movie to the_scale
end tell

gl,

AppleScript and some applications’ implementation of AS allow you to do simple coercions from strings to constants:

return "true" as constant

But again, applications may not support this and it appears Image Events does not:

tell application "Image Events"
	--return class of Eight channel
	set the_color_space to "Eight channel" as constant
end tell

Jon