Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use Xcode to balance and match parentheses Apps
If you need to match and balance parenthesis, braces, and/or brackets for scripting or programming, then look no further than Xcode. Xcode comes with an advanced way of matching these delimiters (parenthesis, braces, brackets) that works with applications that are not supported by Apple such as JMP, a statistical software application.

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.
    •    
  • Currently 3.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[12,750 views]  

Use Xcode to balance and match parentheses | 10 comments | Create New Account
Click here to return to the 'Use Xcode to balance and match parentheses' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Xcode to balance and match parenthesis
Authored by: boredzo on Jan 27, '06 06:36:28AM

many text editors have this feature, including TextWrangler and BBEdit.



[
Reply to This | # ]
Use Xcode to balance and match parenthesis
Authored by: roncross@cox.net on Jan 27, '06 09:59:20AM

Indeed, now you have another way of doing it and you don't have to download a new application for this feature.

It's good to have more choices.

-RLC

---
rlc



[ Reply to This | # ]
Use Xcode to balance and match parenthesis
Authored by: adrianm on Jan 27, '06 12:25:23PM

SubEthaEdit would be my fave for this (should I ever need to match them), but if you've already gone to the trouble of installing Xcode, I suppose that's good too.

But if you have, then this is probably not much of a hint, more of a "well of course you can use Xcode for this, amongst 50,000 other things."

Maybe someone will post a hint that you can use Xcode to syntax highlight C code, too?



[ Reply to This | # ]
Use Xcode to balance and match parenthesis
Authored by: bkazez on Jan 27, '06 07:09:11AM

ParenthesEs! (Parenthesis is the singular.) :-)

---
http://www.benkazez.com/

[ Reply to This | # ]

Use Xcode to balance and match parenthesis
Authored by: roncross@cox.net on Jan 27, '06 10:04:10AM

Thanks, the spelling has been corrected. -RLC

---
rlc



[ Reply to This | # ]
vi
Authored by: TrumpetPower! on Jan 27, '06 08:00:53AM

From perlstyle(1):

When in doubt, parenthesize. At the very least it will let some poor schmuck bounce on the % key in vi. Even if you aren't in doubt, consider the mental welfare of the person who has to maintain the code after you, and who will probably put parentheses in the wrong place.

This is a feature that's been in programmer's text editors for millennia.

Cheers,

b&



[ Reply to This | # ]
Use Xcode to balance and match parentheses
Authored by: juanfal on Jan 28, '06 03:37:43AM
Have you seen AlphaX?

You can programmatically control the behaviour of any thing (double click, syntax-colouring, access to UNIX, AppleScript, program GUI menus, web..) using the really high level and easy to learn Tcl language. MacOSX cames with Tcl as shell (tclsh) (I recommend you to use "rlwrap tclsh" -dowload rlwrap for MacOSX) and since Tiger, MacOSX cames also with the Frameworks Tclframwork and Tkframework for the many applications that use them...

[ Reply to This | # ]
Use Xcode to balance and match parentheses
Authored by: clindberg on Jan 28, '06 09:00:58AM
TextExtras can be installed to give a brace-matching feature (and others) to any Cocoa app.

[ Reply to This | # ]
Use Xcode to balance and match parentheses
Authored by: lcreight on Jan 30, '06 05:36:16AM

Modern versions of JMP let you fence match by presstig command+] or Ctrl+] inside the script editor.



[ Reply to This | # ]
Use Xcode to balance and match parentheses
Authored by: roncross@cox.net on Jan 30, '06 10:38:23AM

I don't have the modern version of JMP. I have version 4 which runs on classic. I always look for applications that I have already to do the job before I go and download a bunch of gui(s).

The more gui(s), the more updates, the more updates, the less productive you are in a work environment. For me the equation is simple.

thx
RLC

---
rlc



[ Reply to This | # ]