Applescript for QuarkXpress 10 to change currency and price format

Hello,

I’m more a designer / support, than a programmer. Actually this is totally new for me, but I found Applescript so helpful to speed up our design process.
We make a product catalog for different countries and we need an applescript to reset currency and prices.

We receive Quark files with prices that could come in any of this three different formats:
US$123.45
$12.345
S/.1234.56

We need to reset al occurrences in Quarkxpress text boxes to exactly
00,00€ or
Q00.00

I can change the currency symbol, but I have no clue how to detect numbers following the currency symbol to reset them to zero.

This is what I did:


tell application "QuarkXPress"
	tell document 1
		set text of every text of every story where it is "US$" to "€"
		set text of every text of every story where it is "S/." to "€"
	end tell
end tell
tell application "QuarkXPress"
	tell document 1
		set text of every text of every story where it is "$" to "€"
	end tell
end tell

Thanks in advance for your help!

Hi! I’m still on v9 as for me. This code should match your needs at least for the first 2 changes you wish to accomplish.
You’ll probably need to change delimit for the full point as well. At least this is a good starting point for you. Well I hope so!

-- !!! IMPORTANT NOTE: this script would modify the delimit table which stores IMPORTANT settings for the 256 ASCII characters of the application !!! Although I wrapped the whole thing in a try block and took some gloves to code it, use it at your own risks !!! If you double-click a word, you'll see wether such character is part of the word or not. Since you'd like to change "words" such as US$123.45 we'll change $ delimit value so that it makes a whole word. MAKE SURE, TOO, THAT THAT CHARACTER IS NOT USED ELSEWHERE IN THE DOCUMENT YOU'D NOT WANT TO BE CHANGED!!!

-- NOTE: delimit is a constant, so do not use quotes around it; its value is one of those: can be contained in word|can start or end or be contained in word|can start or end word|not word member

tell application "QuarkXPress9"
	try
		set OriginalTable to delimit table 1
		set OriginalDelimit to delimit of delimit item 36 of delimit table 1 -- delimit item 36 = $
		set delimit of delimit item 36 of delimit table 1 to can start or end or be contained in word -- delimit item 36 = $
		(*
to know a character code, run the following code with the very character selected in Quark document:
tell application "QuarkXPress9"
	get unicode value of text of the selection -- unicode value of the first 256 characters are the same as ASCII values, if the number returned is over 256 you won't be able to change its delimit values
end tell
*)
		tell document 1
			repeat with i from 1 to count of stories
				tell story i
					set (every word whose contents contains "$") to "00,00€"
					set (every word whose contents starts with "S/") to "00,00€"
				end tell
			end repeat
		end tell
		set delimit of delimit item 36 of delimit table 1 to OriginalDelimit
		set delimit table 1 to OriginalTable
	end try
end tell

Oh thinking a bit further, you can probably first change every occurrence of “S/.” to “$” and then run my code. The problem I was seeing yesterday (I don’t think I was clear on that) was that the fullstop in “S/.” may cut the word in two.

Please replace the relevant snippet with this and you should be OK:

		tell story i
					set (every text where it is "S/.") to "$"
					set (every word whose contents contains "$") to "00,00€"
				end tell

And maybe replace the line storing the delimit table with this one:

		copy delimit table 1 to OriginalTable

HTH.

CMYS, thank you so much. I have to study the code and try it. Its a huge help to start.
Thank you!