* Count parens in a string LOCAL lcString lcString = "(testing) (paren) (counting)" ParenCnt("RESET") FOR lnCnt = 1 TO LEN(lcString) ParenCnt(SUBSTR(lcString,lnCnt,1)) ENDFOR ParenCnt("DISPLAYCOUNT") RETURN PROC ParenCnt( pcChar ) STATIC snOpen, snClose IF pcChar = "RESET" snOpen = 0 snClose = 0 RETURN ENDIF IF pcChar = "DISPLAYCOUNT") ? "Open Parens: ", snOpne ? "Clsoe Parens: ", snClose RETURN ENDIF IF pcChar = "(" snOpen = snOpen + 1 ENDIF IF pcChar = ")" snClose = snClose + 1 ENDIF RETURNThe static nature of snOpen and snClose allow them to act as accumulators for the open and close parens. The RESET option is required to clear any previous values out of those static vars.