Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
 MacRumors Forums Currency conversions in Word or Quark
 User Name Remember Me? Password

 Thread Tools Search this Thread Display Modes
 Jan 11, 2013, 04:15 AM #1 scox macrumors newbie   Join Date: Dec 2012 Location: Istanbul Currency conversions in Word or Quark 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? 0
 Jan 11, 2013, 12:54 PM #2 chown33 macrumors 603   Join Date: Aug 2009 Does it have to be done directly in Word or Quark? What options do those programs have for exporting and importing files? What formats? When I think about the problem as given, I see two potentially separable problems: 1. Find and convert currencies in text. 2. Telling Word or Quark to do #1. If #1 can be accomplished with doing #2, then it might be a simpler problem, or a wider range of possible solutions might be available. For example, suppose Word can be told to export to a format like RTF. Since RTF is just a tagged text format, then any number of other tools that process text can be applied to the RTF, without the need for Word. After the RTF text has been transformed, Word can then be told to re-import the modified RTF. A similar scenario applies for Quark, but I have no idea what Quark's import/export formats are, nor what fidelity issues there might be for a round-trip. As to solving #1, the first thing you need to do is define what currencies to look for, and how those will be represented in text. Once that's been done in a specific way, we can evaluate what text-processing tools might be most suitable. Be specific about currencies. Something that must recognize every currency in the world, in both localized and generalized forms, is a lot more complex (maybe even impossibly complex). Conversely, something that only needs to recognize the Malaysian ringgit as RM or MYR would be much simpler. http://en.wikipedia.org/wiki/ISO_4217 Also specify any required context for currencies, such as localized assumptions. An example of a localized assumption is that \$ in the US means the USD (US Dollar) currency. Australia's currency is also called "dollar", and the symbol is AU\$, but there may be others, as well as an implicit assumption that in Australian publications an unadorned \$ means Australian dollar (I'm guessing about the assumption, as I'm not Australian). There are also some possibilities for making a service (the Services submenu under the app's self-named menu). For a service, you would manually select a currency amount, choose the service, and the result would paste in the original amount plus a converted value. I think services can also be scripted, so that may be another approach after the conversion service has been created. Services can be created in Automator, and then can use Automator actions as well as other scripting languages. 2
 Jan 14, 2013, 07:49 AM #3 scox Thread Starter macrumors newbie   Join Date: Dec 2012 Location: Istanbul Hey, thanks a lot for the response. You are totally right, I was trying to get Applescript to perform the conversion on a string. Oops. This weekend, I started trying to find a way to extract the currency figure as a string, change it to a number, and then perform the conversion. So far, I have tried to do it directly in Quark. Exporting seems like a reasonable option, but I haven't yet figured out how to put the new figure back into the text, much less get it out. Basically, I'm new enough at this that I didn't realize the real scale of the problem I was tackling. Oops. My outline of the component operations keeps growing: - Search text for currency symbol - read the numeric string behind the symbol (stopping when the value ends) - save the string elsewhere (in the code, or in a list) - convert the sting to a number - calculate the conversion of the number - save the conversion as a string - insert the conversion string back into the text - format it (put a \$ or € in front of it) - move to the next incidence of the currency I kind of makes my head spin. As to your question about currencies, it is easier than I made it seem. It doesn't need to be taken from another source and the program doesn't need to recognize all currencies. Our publications are dedicated to a single country, so the writers send us most figures in the local currency, and the editors perform the conversion to either dollars or euros. As long as the key parameters can be set by the editor, I think the whole project is a bit simpler. I'll play around with the services you mentioned. I was taken in by Applescript, initially, because my version of MS Word (2008) didn't support macros, and I wanted to design something for myself and my colleagues, who I later found out are all running various versions of Word from 2000 to 2011, on different Mac OSs. The company is, to put it politely, a bit technologically backwards. Applescript seemed like a good way to get a solution that could work for the whole department, despite the technological specifics. In any event, thanks for the advice. I'll keep picking at the problem until I can get to the smallest bits of it, and I'll post any little successes I have. As it stands, it might be a project that is just far too out of my league, but it's been fun to play with. Thanks again for the reply. 0

 MacRumors Forums

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 Similar Threads thread Thread Starter Forum Replies Last Post kallisti Digital Photography 12 Jan 8, 2014 05:25 PM mr.bee MacBook Pro 50 Nov 5, 2013 11:47 AM dr2391 iPhone 1 Dec 20, 2012 01:55 PM Krash11554 iPhone Accessories 2 Sep 27, 2012 09:23 PM irnchriz Apple TV and Home Theater 6 Sep 24, 2012 02:42 PM

 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News and Article Discussion     MacRumors.com News Discussion     Mac Blog Discussion     iOS Blog Discussion iPhone, iPod and iPad     iOS         iOS 8         iOS 7         iOS 6         iOS 5 and earlier         Jailbreaks and iOS Hacks     iPhone         iPhone Tips, Help and Troubleshooting         iPhone Accessories         iPhone Launch Meetups         iPhone Wallpapers etc.     iPad         iPad Tips, Help and Troubleshooting         iPad Accessories         iPad Launch Meetups         iPad Wallpapers etc.         iPad Apps     iPod touch         iPod touch Accessories     iPod     Alternatives to iOS and iOS Devices Apple Applications     iPhone and iPod touch Apps     iPad Apps     Mac Applications and Mac App Store Apple Hardware     Desktops         iMac         Mac Pro         Mac mini     Notebooks         MacBook         MacBook Pro         MacBook Air     PowerPC Macs     Apple TV and Home Theater     Mac Peripherals     Buying Tips and Advice Apple Systems and Services     Mac Basics and Help     OS X         OS X Yosemite (10.10)         OS X Mavericks (10.9)         OS X 10.8 Mountain Lion         Mac OS X 10.7 Lion         Mac OS X Server, Xserve, and Networking     iCloud and Apple Services     Windows, Linux & Others on the Mac     Programming         iPhone/iPad Programming         Mac Programming         App Store Business, Legal and Marketıng Special Interests     Mac and PC Games         Console Games     Digital Audio     Visual Media         Design and Graphics         Digital Photography         Digital Video         Web Design and Development     Apple Collectors     Distributed Computing Mac Community     Community Discussion         Apple, Industry and Internet Discussion         Current Events         Politics, Religion, Social Issues     Picture Gallery         UI Customization     Site and Forum Feedback         Mac Guides Private Forums Archive     Wasteland     Archives of Old Posts         MacRumors News Discussion (archive)         MacBytes.com News Discussion         Buying Tips, Advice and Discussion (archive)         Community         Daily Tunes Site Discussion and Feedback         Event Archives             Macworld San Francisco 2008         Games         General Mac Discussion         Hardware Rumors         iPhone Purchaser Meetups         Leopard Event Meetups         Mac Help/Tips         Mac OS X 10.3 (Panther) Discussion         Mac Scene         Macintosh Computers         MacRumors Old Skool         Marketplace Archive 1 (Posts count)         Marketplace Archive 2             iPhone Marketplace Archive         Music Discussion         New Mac Application Announcements         Product Recommendations/Reviews         Site News         Switch Stories         Web Design and Development (archive)         Past Contests             1,000,000 Post Contest             2,000,000 Post Contest             3,000,000 Post Contest             4,000,000 Post Contest             5,000,000 Post Contest             Ten Million Post Contest

All times are GMT -5. The time now is 02:11 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps
 Contact Us - MacRumors Forums - Archive - Privacy Statement / DMCA Agent - Top

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC