Changing font size and font in apple script

Hi All,

I am new to applescript, i got some error from my below script

Actually i want to change the Font size and Font in style “PREH1” while compiling the script it does not shows any error but while running the script, the script runs but action is not taken place it retains the earlier style only. So please check, i am looking forward your help.

May i get some sample script develop for Quarkxpress from you for developving script knowledge.

The script is below:

tell application “QuarkXPress”
tell document 1
set nstyle to count style spec
repeat with a from 1 to nstyle
if name of style spec nstyle is “PREH1” then
display dialog the size of style spec nstyle is “PREH1”
set size of style spec nstyle of “PREH1” to “15pt”
set font of style spec nstyle of “PREH1” to “Horley Old Style MT”
end if
end repeat
–display dialog nstyle
end tell
end tell

Thanks
Elansezhian

Hi,

you made a mistake in the “repeat with” instruction. You’re using the “a” variable (“repeat with a from 1 to nstyle”) but you will not deal with this variable the next lines. So, why did you create it?

If I keep your structure, this works:

tell application "QuarkXPress Passport"
	tell document 1
		set nbstyle to count style spec
		set namestyle to name of every style spec
		repeat with a from 1 to nbstyle
			if item a of namestyle is "PREH1" then
				set size of character attributes of style spec "PREH1" to 120
			end if
		end repeat
	end tell
end tell

As you can see I really used the “a” variable this time and I added the line: “set lstyle to name of every style spec” to get all the style names. Then I can deal with them.

I still have a question: why do you use a loop? Since styles are objects identified with names. talk to them directly using their names! So, I prefer this one:

tell application "QuarkXPress Passport"
	tell document 1
		set namestyle to name of every style spec
		if "PREH1" is in namestyle then
			set size of character attributes of style spec "PREH1" to 18
		end if
	end tell
end tell

I hope it helps.

Model: MacPro Dual-Core Intel Xeon 2.66 GHz - QuarkXpress 6.5
AppleScript: 2.1.1
Browser: Firefox 2.0.0.14
Operating System: Mac OS X (10.4)

G’day laurent

It works fine and thanks for your help.

Thanks
Elansezhian