Jan 27, '06 05:12:00AM • Contributed by: roncross@cox.net
I often have to script non-supported applications such as JMP that have nothing in common with the Mac except for running on the platform. If you script a lot, and have to do a lot of delimiter matching, then you know how frustrating it can become balancing these items. The next time you have to match parenthesis, bracelets, or brackets, whip out Xcode. You will have to install this from your Developer's CD if it is not installed on your machine. Open your script document in Xcode; it can directly open up most documents.
If you double-click on a closing or opening parenthesis, brace or bracket, the entire text will be highlighted between the matching delimiters. This will allow you to see if you have a missing or extra parenthesis. The good news about this is that you don't have to compile anything. The bad news, of course, is that it takes time to use Xcode to balance the delimiters, but it may take you more time without it, depending on the scripting language.
The other balancing feature of interest is that you can balance these delimiters outside of your selection. For example, you can double-click on a delimiter to highlight the text. In Xcode, go to Format: Balance and the next matching delimiters outside of your selection will be highlighted. I have found that this makes life easier when writing scripts that require nesting structures, and scripting languages that are not supported by Apple.
Once you match up your delimiters, simply copy and paste your scripting code back into the script editor for that application and run it. One other note is that Apple's Script Editor is capable of doing the same thing, but only if the code is compiled. So if you are working with another scripting language such as JMP, Apple's Script Editor will not work.
