Currency conversion in Quark with Applescript

Discuss AppleScripting for QuarkXPress 10, 9 & 8 (and before)
Post Reply
MrSean
Posts: 0
Joined: 10 Jan 2013, 09:46

Currency conversion in Quark with Applescript

Post by MrSean » 10 Jan 2013, 04:30

I'm new to AppleScript and attempting to automate one of the more time-consuming tasks that I do on a day-to-day basis: currency conversions.
I've been trying to develop a script that will search a document for the relevant currency symbol (provided by the user), calculate a conversion of that currency (according to a user-defined rate), and then include the new calculation in the text (in the user-defined target currency), such that it appears directly after the original in parentheses.
I typically start with a paragraph like this:
The three richest states in Malaysia by GDP were Kuala Lumpur, with RM73.536 billion; Sarawak, RM49.48 billion; and Penang, RM46.744 billion.
I am trying to write an AppleScript that will prompt the user for the currency symbol (in this case, RM), request the target currency symbol ($), find and calculate each conversion automatically according to the user defined rate (RM1 = $0.328699), and include it in the text. If it could round the number to the nearest hundredth, that would be stellar.
The output I want, ideally, would look like this:
The three richest states in Malaysia by GDP were Kuala Lumpur, with RM73.536 billion ($24.17 billion); Sarawak, RM49.48 billion ($16.26 billion); and Penang, RM46.744 billion ($15.27 billion).
I understand that there's the possibility that the conversion would drop into the hundreds of millions, and that it is thus important for the conversion to be aware of the word following the currency. I don't even know where to begin tackling that part of the problem.
Basically, so far, I've managed only to prompt the user for the currencies and rates involved. I created a search/replace script for other common formatting features, but this one has me completely stumped.
Any suggestions?

Post Reply

Return to “QuarkXPress 8, 9 & 10: AppleScript”