Article Preview
Buy Now
FEATURE
Transmogrify Your Text
Converting text files with RBScript
Issue: 9.1 (November/December 2010)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 35,078
Starting Page Number: 26
Article Number: 9107
Resource File(s):
9107project.zip Updated: 2010-11-01 16:57:16
Related Link(s): None
Excerpt of article text...
Years ago one my favorite products was software called OneClick. (It was for Mac OS 9 and sadly never made the transition to Mac OS X.) OneClick was ostensibly macro software that let you automate actions, but it had a powerful scripting language that was similar to REALbasic in many ways. With OneClick you built floating palettes of buttons and you could script what happened when you clicked the buttons. Because OneClick was always running, with your palettes and buttons always available—and editable—it made a terrific environment for doing quick text manipulations. I still miss it and while I love REAL Studio, sometimes it's a pain to have to compile an entire app just to run a few lines of code.
Where this shows up most often for me is in working with text files. I've mentioned before that I love plain text files because of their simplicity and universality, so I use them as data storage for all sorts of projects. But that means I'm often running into situations where I need to do some text manipulation on those files. Sometimes I can use a text editor like BBEdit to do a find/replace, but often I need to do a whole sequence of finds/replacements, or perhaps do some context-sensitive decision-making which is beyond even regular expressions' ability. In those situations I turn to REAL Studio.
While it's not hard to write a drag-and-drop app that lets me do powerful text conversions easily, I've found I keep reinventing the wheel. It's also a hassle to have to fire up REAL Studio and recompile a new version of my app just for a tiny code change. So recently I got smart and created an RBScript-based system that lets me easily create external scripts to do whatever kind of text conversion I need!
How Transmogrify Works
The most significant aspect of Transmogrify is that it
never modifies the original file. It always saves changes as a new version of the file. Thus the workflow for Transmogrify is:
Run the app.
...End of Excerpt. Please purchase the magazine to read the full article.