How can I get TextPad to count the number of times "68" occurs in a file?
(Note: "68" may occur multiple times in a row).
Counting occurrences
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
gcotterl
- Posts: 255
- Joined: Wed Mar 10, 2004 8:43 pm
- Location: Riverside California USA
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
I need a TextPad macro to insert the statistics including a count of string occurrences.
How to capture that count from the lower left corner and include it in the document with other specs inserted with Edit/Insert/Statistics?
I cannot find any command that returns a string count except in the status line.
How to capture that count from the lower left corner and include it in the document with other specs inserted with Edit/Insert/Statistics?
I cannot find any command that returns a string count except in the status line.
Hope this was helpful.............good luck,
Bob
Bob
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
There's no way to do this within TextPad that I'm aware of.
It's another job for a one-line script. E.g.
It's another job for a one-line script. E.g.
Code: Select all
perl -ne "$n ++ while /text_to_search_for/g ; END { print $n }" filename- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Thanks ben_josephs for confirming my fear.
Guess I could run the perl script as a tool, direct the result to a file and do a copy/paste all within the same macro. Will have to pull out my old perl stuff that I have not looked at in years.
Thanks for the suggestion.
Guess I could run the perl script as a tool, direct the result to a file and do a copy/paste all within the same macro. Will have to pull out my old perl stuff that I have not looked at in years.
Thanks for the suggestion.
Hope this was helpful.............good luck,
Bob
Bob
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Unfortunately, TextPad won't let you run a tool in a macro. Strange and sad, but true.
If you can get the tool to send its output to the clipboard you can do what you want in two steps: run the script and paste its result into your document.
You can get the script's output onto the clipboard either by redirecting it there (e.g., by calling Perl from 4NT (perl whatever.pl > clip:)) or by getting the script itself to send its output there (e.g. by using the Perl module Win32::Clipboard).
Alternatively, you can use a keyboard stuffer such as AutoIt or MacroScheduler to send key strokes to TextPad that run the tool and paste the output. Or you can do it from within the script itself, using the Perl module Win32::GuiTest.
If you can get the tool to send its output to the clipboard you can do what you want in two steps: run the script and paste its result into your document.
You can get the script's output onto the clipboard either by redirecting it there (e.g., by calling Perl from 4NT (perl whatever.pl > clip:)) or by getting the script itself to send its output there (e.g. by using the Perl module Win32::Clipboard).
Alternatively, you can use a keyboard stuffer such as AutoIt or MacroScheduler to send key strokes to TextPad that run the tool and paste the output. Or you can do it from within the script itself, using the Perl module Win32::GuiTest.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact: