Page 1 of 1

Number of occurrences of "text" in file

Posted: Mon Oct 28, 2002 2:28 pm
by adriand
Does anyone know how to obtain a count of the number of occurrences of a specific text string (eg. "EXEC SQL") in a file?
Better still, once the number of occurrences in known, does anyone know of a way of moving the cursor directly to (say) the 43rd occurrence in the file?
BACKGROUND: Supporting an application that uses generated Cobol programs. Subsequently, resultant source code is very large spagehetti code. 100k lines of source is typical with many much, much bigger. Diagnostic tool identifies that the "problem" happened with the nth occurence of given statement.

Re: Number of occurrences of "text" in file

Posted: Mon Oct 28, 2002 3:11 pm
by Andreas
Getting the count:
Replace
EXEC SQL
with
EXEC SQL
(scope: active document)
and have a look at the status bar

Jumping to the n-th occurrence: no idea

Re: Number of occurrences of "text" in file

Posted: Mon Oct 28, 2002 3:51 pm
by jmalyon
Set up a quick on-the-fly macro ([ctrl]-[shift]-r) to search ([ctrl]-f) for the next occurrence of the string. Start from the top and playback the macro ([ctrl]-F7) 43 times.

Re: Number of occurrences of "text" in file

Posted: Mon Oct 28, 2002 4:04 pm
by jmalyon
P.S. As a matter of routine I hit the "undo" button immediately after doing that same-to-same replace that Andreas suggested. That way you're not at risk for messing up capitalization or having a slight typo in the "replace" field.