Topic: Search specified columns and extract (1 of 3), Read 19 times
Conf: Search and Replace
From: Bill Hanus
Date: Monday, October 09, 2006 02:31 PM

I use the provided "extract" macro often but at times need to search only specified columns for a text string and extract the entire line for each occurrence. Is there a simple way to modify the extract macro to only search specified columns?

 


Topic: Re: Search specified columns and extract (2 of 3), Read 15 times
Conf: Search and Replace
From: Christian Ziemski
Date: Monday, October 09, 2006 03:05 PM

On Mon, 09 Oct 2006 14:31:00 -0400, Bill Hanus wrote:

>I use the provided "extract" macro often but at times need to search
>only specified columns for a text string and extract the entire line
>for each occurrence. Is there a simple way to modify the extract
>macro to only search specified columns?

Bill:

A quick, but hardcoded version:


Change the macro here:


//
// Process each search occurrence.
//
repeat(ALL) { // Repeat forever until Search() breaks out
Search(@103,ERRBREAK) // Search for next occurrence
Begin_Of_Line // Go to beginning of line
Reg_Copy(105,1) // Copy the line to T-Reg 105
Buf_Switch(#104) // Switch to destination file
Reg_Ins(105) // Insert (append) the line
Buf_Switch(#103) // Back to the original file
Line(1,ERRBREAK) // Advance to next line to continue search
}


into something like this:


repeat(ALL) { // Repeat forever until Search() breaks out
Search(@103,ERRBREAK) // Search for next occurrence
if ((Cur_Col >= xxx) && (Cur_Col < yyy)) {
Begin_Of_Line // Go to beginning of line
Reg_Copy(105,1) // Copy the line to T-Reg 105
Buf_Switch(#104) // Switch to destination file
Reg_Ins(105) // Insert (append) the line
Buf_Switch(#103) // Back to the original file
Line(1,ERRBREAK) // Advance to next line to continue search
} else {
Char(Chars_Matched) // Advance past found string
}
}


where xxx and yyy are the columns the search string has to begin in.

To make it more comfortable and flexible you can add a
Dialog_Input_1() command at the beginning to be able to type in the
columns in dialog on every usage.


Please note: The above is not tested and should only be a hint!

Christian

 


Topic: Re: Search specified columns and extract (3 of 3), Read 16 times
Conf: Search and Replace
From: Bill Hanus
Date: Tuesday, October 10, 2006 11:48 AM

Christian,
Thanks for the hint. With one minor change, (putting an equal sign before the yyy) I am able to put the starting column in for the xxx and yyy as you described and it worked great.

Bill