running script in InDesign CS5.5 gets different results

I have a script fragment that gets a character’s position (superscript, normal or subscript). When I run the script with AppleScript Editor, it returns a value of “superscript”, “normal” or “subscript”. However, when I run it through the scripts panel in InDesign it returns a value of “«constant ****norm»”. This becomes an issue because when I write the scripts I don’t run them through InDesign. I get the scripts working and distribute them to my co-workers who then start running them natively in InDesign, which of course causes errors and makes me look stupid!!

Any ideas why this is happening? Thanks!

The mechanics of exactly how or when a constant exposes itself in raw event form eludes me to some extent, but that is what is taking place. Testing against the standard dictionary term should leave you with a workable result.
You didn’t post code, so yours may differ in the targeting, but this would return true if superscript:

tell application “InDesign CS”'s document 1
(text frame 1’s word 3’s character 1’s position) = superscript
end tell

Here is some code that is giving me issues:


tell application "Adobe InDesign CS5.5"
set myFrame to item 1 of selection
set lineJustification to justification of line 1 of myFrame as string

tell character 1 of line 3 of myFrame to set charPosition to position as string
--This is where I sometimes get a result of  "«constant ****norm»" or "normal"

end tell


I don’t know if this helps or not, but this is just one instance of where I am having problems.

justification and position are enumerated constants (in fact integer values)
which are only valid in an Indesign environment

Thanks Stefan. Can you explain that a little more for me. I look in the dictionary and it says it should return normal/superscript/subscript/OT superscript/OT subscript/OT numerator/OT denominator. Why does the dictionary say it should return one of these values if it is in fact an integer value?

AppleScript uses often the data type enumerated constant,
which is a 4-letter raw AppleEvent code (actually an integer) represented by a human readable value (e.g. position).
The internal integer must match the entry in the appropriate (application) dictionary.

These constants can be coerced to string but then they cannot be used anymore as constants
and cannot be coerced reversed

Thanks Stefan! that is a great explanation of this.

In one of my apps, I have to trap for exactly this issue. It seems more prevalent of the first time something is called form InDesign, and it happened in CS3,4, or 5. In my case it was getting the ruler units for a document.
I had to write a big if/else block to handle «constant ****zinc» or whatever it was I was getting, and then convert that into what I normally expected. It was a huge pain, but my handling of it works now without problem.
BTW I only ever see that in my one app and have never seen it pop up in hundreds of other InDd scripts/apps I’ve made. Very weird.

The problem with units in InDesign is complicated by the fact that you’re also dealing with a terminology conflict there.