How to skip lines in a KSH?

hi,

I have a shell script that searches for a particular pattern in all the files inside a directory, and gives the count of that pattern occurences in a file.

Now i should not count the pattern if it exists in side a { .... }, as shown below.

{
......
.....
.... PATTERN1.......
....
}

How can i get this in a shell script..

Thanks

this looks similar to what you asked here