So, I've had a little success with the Style Guide script folks here were so helpful with, and this has brought to light a new challenge currency conversion. This one has me completely stumped though, and after trying for two weeks and getting... well... nowhere, I appeal to ya'll for help.
For MS Word and Quark XPress, I've been trying to develop a script that will search a document for a user-defined currency, calculate a conversion of that currency (according to a user-defined exchange rate), and then include the new calculation in the text (in the user-defined target currency), such that it appears directly behind the original in parentheses.
Say I 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. That was the easy part, and since I've been stumped for so long, I felt it was time to ask around.
Any suggestions?
For MS Word and Quark XPress, I've been trying to develop a script that will search a document for a user-defined currency, calculate a conversion of that currency (according to a user-defined exchange rate), and then include the new calculation in the text (in the user-defined target currency), such that it appears directly behind the original in parentheses.
Say I 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. That was the easy part, and since I've been stumped for so long, I felt it was time to ask around.
Any suggestions?