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