AS save as app returns different value for Image Mode

I counter issue when saving my script as application, to illustrate the problem easier I extract the script as below:

tell application "Adobe Photoshop CS2"
	activate
	-- with an image file open
	set theMode to mode of current document as Unicode text
	display dialog theMode
end tell

This script works fine (with an image open in PhotoShop) when launch from AS itself, it will prompt as “RGB”, “CMYK” or others. However, when I save it as application (run only) and launch the app, it prompts me different answer (such as <<constant ****e082>>).

So I am stuck here, please advise! TIA!

Hi, cits.

That’s very likely to be because your script editor knows how to decompile compiled tokens back to source-code keywords, whereas a script applet doesn’t.

If you want keywords as text in an applet, you’ll have to write the text into the script. I don’t know if the following actually works as I don’t have Photoshop, but it illustrates the idea:

tell application "Adobe Photoshop CS2"
	activate
	-- with an image file open
	set theMode to mode of current document
	set possibleModes to {RGB, CMYK} -- etc.
	set textEquivalents to {"RGB", "CMYK"} -- etc.
	repeat with i from 1 to (count possibleModes)
		if (item i of possibleModes is theMode) then
			set modeAsText to item i of textEquivalents
			exit repeat
		end if
	end repeat
	display dialog modeAsText
end tell

Edit: Script corrected in the light of cits’s comment blow.

Hi NG,

Thanks a lot for your help! Your approach is working great when this line

set theMode to mode of current document as Unicode text

is changed to

set theMode to mode of current document

Thanks again!

Oops! Sorry about that. :rolleyes:

Now corrected.