First post here.
I need to scan a file (NC milling output) with, potentially, tens of thousands of lines of text, looking for keywords.
Every time I find a keyword, say, a tool change command, I want to print out twenty lines - the ten lines above this line, and the ten lines below it, inclusive.
I would eventually need to save this output to a second file but that should be the easy part.
I figured that I could scan the document twice -
On the first pass, store the line number for each line that gets a hit.
On the second pass, print the "hit" lines with its twenty accompanying before- and after- lines.
I have a program that does this using awk (unix) but we are moving our systems to Windows and was hoping to get this moved over and use it as Windows programming practice.
I was initially hoping to do it as a Windows Forms utility (for the users to run) but that seems a bit clumsier with RichTextBoxes not really seeing the text as lines. ??
Are there any other methods or logic that you would recommend to approach this? - something that doesn't require recursive bit shifting and magic potions, though - string handling in C/C++ already seems convoluted enough to me! ;)
Thank you in advance for any advice!