Quark script used to work in 9.2, not now in X

I know it’s clunky, but this is a script I wrote years ago to figure out how long newspaper stories are going to be.
You pick a folder and it imports the stories one at a time does a character count, does some math and pastes into a text box the name of the story and the length in inches

But ever since I switched to OSX i get a message “storyLength is not defined”.
Well… to be truthful… the first time I ran it it told me all the stories were the same length, but I think that had something to do with that invisible file? at the top of every folder so i worked around that by importing files from the second file onward.
If I hard code in a path like “Macinstosh HD:Spam” (where spam is a word document) it works fine, so the problem has to be in the path? and the importing of the text?

Can anybody tell me what needs to be changed?
Thanks,
JA


choose folder “choose this week’s news folder”
set thePath to result as string
set numberOfStories to count of (list folder alias thePath)
set counter to 0
tell application “QuarkXPress™ 4.11”
activate
tell default document 1
set automatic text box to false
end tell

make document at beginning
tell page 1 of document 1
	make text box at end with properties {bounds:{"8.5 cm", "5 cm", "10 cm", "10 cm"}}
end tell
tell page 1 of document 1
	make text box at end with properties {bounds:{"2 cm", "2 cm", "27 cm", "10 cm"}}
	make text box at end with properties {bounds:{"2 cm", "10 cm", "27 cm", "15 cm"}}
end tell

tell page 1 of document 1
	repeat with i from 2 to numberOfStories
		set storyFile to item i of (list folder alias thePath)
		tell text box 1
			try
				set story 1 to alias (thePath & storyFile)
				set characterCount to count of characters in story 1
				set storyLength to (characterCount / 156.4)
			end try
		end tell
		copy (storyFile as text) & return to after story 1 of text box 2
		copy (storyLength as text) & return to after story 1 of text box 3
	end repeat
	delete text box 1
end tell

end tell

  1. Look at this line of applescript code:
    set story 1 to alias (thePath & storyFile)

  2. change this line to:
    set story 1 to (thePath & storyFile) as alias

  3. Run the script: it will work!!!

Regards,
Luca

That was it!
Now can anyone tell me why such a simple change was needed?

Is there a thread discussing the difference between 9.2 and OSX so I can find little boogers like this one before they stop me from getting work done?

many thanks
JA

It’s not a difference between Mac OS 9.x and Mac OS X… Your script runs fine on Mac OS X if I target QuarkXPress 6.0.

It depends on the way QuarkXPress 3.3x, 4.x and 5.x run under the Classic environment. In most cases, you have to convert or coerce some value.
For example, create a new document, then a new text box and select it. Type this script and execute:


tell application "QuarkXPress Passport™ 4.11"
set theWidth to width of bounds of current box of document 1
end tell

You’ll get this result:

-->	«data FXHM00F648B0»

You have to add these two lines if you want to see the value in centimeters:


set theWidth to coerce theWidth to centimeter units
set theWidth to coerce theWidth to real

I hope this could help :wink:
Luca