Number of occurrences of "text" in file

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
adriand

Number of occurrences of "text" in file

Post 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.
Andreas

Re: Number of occurrences of "text" in file

Post 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
jmalyon

Re: Number of occurrences of "text" in file

Post 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.
jmalyon

Re: Number of occurrences of "text" in file

Post 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.
Post Reply