A Quark script to change certain fonts to dingbats.

I am trying to write a script to change some fonts to dingbats. I only want the characters which occur with a tab before and after it not all of them. I have made one but I can only get it to work where it changes all of the characters.
Here is what I have that does’nt quite work.

tell application “QuarkXPress”
activate
if not (exists document 1) then
display dialog “Please open a QuarkXpress Document”
–tell the current document
else
tell document 1
try
set (font of every character of every story where ¬
(it = " l ") or ¬
(it = " n ") or ¬
(it = " u ") or ¬
(it = " ¯ ") or ¬
(it = " ª ") or ¬
(it = " © ") or ¬
(it = " V ") or ¬
(it = " 2 ")) to “NCTC WINGDING”
beep 1
on error
beep 4
end try
display dialog “Your fonts were changed sucessfully” buttons {“OK”} default button 1
end tell
end if
end tell

This will work if I take out the tab before and after the Key stroke I have put in.
I would really appreciate some suggestions

Thanks Alot!!

What you want is change some characters.
What you tell the script to do is to change a character. But between the quotes is a space a character and another space.
That is a big difference.

More than one character could be a word or just text.
Try this:

				set (font of every text of every story where ¬
					(it = (tab & "n" & tab)) or ¬
					(it = ((ASCII character 9) & "u" & (ASCII character 9))) or ¬
					(it = (thePrefix & "x" & theSuffix))) to "NCTC WINGDING"

Tab and ASCII character 9 are both the same.
For the 3rd option (with prefix/suffix) place:

set thePrefix to ASCII character 9
set theSuffix to " "

at the beginning of your script.
As you see thesuffix could be any text or character, here it is only a space.

Good luck.
Kjeld

Thank You for the help.
I tried these and I have not got it yet. Also I noticed that my characters I am changing have a tab before them and a space then a tab after them.Not a tab on either side. If I remove everything from the quotes except for the key stroke it works and changes them all, but I only want to change the ones after this tab with the space and the tab after them.
When you said to try

For the 3rd option (with prefix/suffix) place:
Code:
set thePrefix to ASCII character 9
set theSuffix to " "

do you put this before the set (font of every character of every story where ¬

Yes. These are the very first lines of your script. Followed by
tell application etc.
You can change theSuffix to:

set theSuffix to space & (ASCII character 9)

Notice that this line:

set (font of every character of every story where

should be

set (font of every text of every story where

Since you want to change more than one character.

Thanks alot. That was all I had wrong the word text instead of character. Also It would not work with the or statement for each character I was changing. I just wrote the try statement over and put in the new character each time. Also when I changed the letter I wanted and the space it messed up the ledding because of the new font. I jest added a tell to the beginning to get rid of those first. The only thing I would like to add to this script is ,for some reason when I copy my text to quark I get a space at the beginning of each line which I need to take out. Currently I use find and replace to do all these things one at a time. This script will save me a lot of time. Adding that last feature would do it all. Again Thank You So Much . Learning about scripts is cool and I can see where it will realy help me.

I just got the last part I needed figured out. I used

try
set (text of every text of every story where ¬
(it = return & " ")) to return
beep 1
on error
beep 4
end try
try

With everything else this script is working perfect for me.
Thanks Alot…

Now what if there are two or more spaces after a return?

Kjeld

I just put in 2 spaces inside the quotes. It is wierd though. Sometimes it does not change them if I type in an extra space in the document after the original space I want to remove, only if I type it before the space I want to remove. This stuff can be a little tricky. Especially if you do not know the cammands and abbreviations for each program you are writing script for.

Think about this one for a while. :wink:

set spaceBefore to (return & space)

tell application "QuarkXPress Passport"
	tell document 1
		set theTest to true
		repeat while theTest is true
			try
				set (every text of every story where it is spaceBefore) to return
			on error
				set theTest to false
			end try
		end repeat
	end tell
end tell

I tried what you sent and can not quite seem to get it to work.
I assume Regular QuarkExpress works the same as QuarkExpress Passport.
I think I understand. At the beginning of the script you are setting up parameters for this script then using that to easily identify them for the rest of the script cammands you want to achieve.
It is not easy to know how to represent different commands. So far I have just tried really simple things where I have looked at other scripts and used them to figure out things I wanted to do.
I wish I had more time to learn this. I know the more I learn the more chances I will find ways to make my work easier and cut out little steps I do on every job.

:smiley:

To see the working of the script there are supposed to be a couple of space before some new paragraphs.
If you’re working with quark 6 it should work. I don’t know if it works with previous versions.
You understood well about the parameters. Advantage of this is that you can make a script more universal. And if there are changes you only have to make them at one place instead of more places.

Buy this book if you thinking you want to get more out of scripting QuarkXpress. There are dozens of sample scripts on the cd.
If you have more textual changes, take a look at this script in combination with this app.
It’s way faster to make these kind of changes in a text editor.

Good luck.
Kjeld

I will look into those links. They should help Alot.
Thanks Again for all the help. :smiley: