Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding mismatched braces

Status
Not open for further replies.

blasterstudios

Technical User
Dec 30, 2004
128
US
I have a php document with 211 left braces { and 210 right braces }. I've searched over and over to see if i can find it and i just can't. does anyone know of an easy way to find the missing brace? i've tried dreamweaver's balance braces but it doesn't help me much. it still takes forever. maybe someone out there really likes doing this and can look at my code and find the problem. it started after i added 2 sections of code and i've gone through both of those sections and can't find it, so i went through the whole document and still couldn't find it. any help would be appreciated.

thanks.
 
Textpad and the php/html syntax definition, oooh pretty colours.

vim is better, everything goes red when you get one wrong.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
got a linux server at hand ? vi filename

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
no, i don't, sorry
this is driving me crazy. i tried textpad, but it just seems to be the same process as using dreamweaver. there's got to be a macro or something i can setup to check this.
 
textpad even misses some of them, so i don't even think its going to be useful.
 
What does your indentation style look like? If it's something like:

if (<condition>)
{
if (<new_condition>)
{
//new block
}
else
{
//block
}
}

then you could always print out the script in a non-proportional font and line up the braces with a ruler.

Even if your style doesn't work well with using a rule, sometimes just printing it out can let you see stuff you didn't before.

You can also try commenting out entire blocks that you know have well-balanced braces.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
mail code to kev(at)virtualkev.com with a return address, lets see how fast vi will deal with it ;)


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
ooh. sorry man. i would, but i sat down and actually used my brain. Earlier i was checking the whole page for { and } and returning 1 } short. Well, i got smart, and started selecting groups of text that I knew had a start and an end. i finally found 1 that had 6 {'s and 5 }'s. after about 10 minutes of analyzing that section, found the missing }. Thanks for the offer. is VIM something i can copy to my server (which is on unix/linux) and run it from there?

Thanks again.
 
if its linux, vim should already be there, type vi --help and see what ya get :) newer versions perform better, if you run under colour xterm, it should prove most effective.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top