Difficult Quark Question connected to casting

Hello,
I have a script that works pretty well. It interrogates a Quark file, and writes the information into an XML file. There is though a little bug that is a trifle annoying. Sometimes it works fine, and at other times it doesn’t.

This statement should produce a string something like ‘top justified’.

set strValue to coerce (vertical justification as string) to string

However for reasons best known to itself it often produces a string with this value ‘«constant ****TPJS»’.

When I put in a display dialog statement to try and debug it will sometimes display this second value, but when I press cancel it seems to switch back to the one I want. I’ve ran my script several times on different Quark files sometimes it works, and sometimes it doesn’t. It isn’t throwing an error if it did strValue is set to empty. It is without a try block but this contrary behaviour is puzzling me.

I’m guessing that might be something to do with the cast. I’ve tried various versions of the statement, all seem to work sometimes.

Any help or advice would be much appreciated.

Dan.

This seems to be the solution, and seems to be reliable. I’ll do some more testing.


										set strValue to coerce (vertical justification as constant) to string
										if strValue is equal to "tpjs" then
											set strValue to "top justified"
										else if strValue is equal to "cent" then
											set strValue to "center"
										else if strValue is equal to "btjs" then
											set strValue to "bottom justified"
										else if strValue is equal to "full" then
											set strValue to "full"
										else
											set strValue to "full" -- by default set it to full
										end if