Topic: Can you use a Text register as part of a Search? (1 of 3), Read 14 times
Conf: Search and Replace
From: LeRoy Stevens
Date: Saturday, March 07, 2009 10:21 PM

I am trying to create a macro that will allow a user to input part of the search criteria (the 3 numbers in a line column 76, 77 and 78 {sample line below}). I can get their input and place it in Text_Register 20 with the Dialog_Input command but I do not understand how to use that Text_Register.

My search line: Search("|<5200|*Reg_Ins(#20)",ERRBREAK)

I thought that would skip down to a line that started with 5200 and then search for 035 in that line(in this example). Another problem (used fixed 035 for initial test but that is also marking any line that has 035 in it and I only want the lines that have 035 in column 76, 77 and 78. Once I get that figured out, I was hoping that I could use Text_Register 20 or larger (in this case if a user enters 035 the search would search for 035 (columns 76-78) or 036 or 037. Once I get the proper hits, I want to move to the Begin_Of_Line (this should be in a If logic)
My results are no MetConvTst.txt file (the output file) and a 0 byte CTXLineCount.txt file. In VEdit, Help menu, Text Registers I can see the 035 in T-Reg 20.

Sample line of file I am pulling blocks from:
5200HOMETOWN BUFFET 1330463002PPDREG.SALARY0204090902040351042000010002021

//Author: LeRoy Stevens Feb. 03, 2009

File_Delete("\\Bisysftp\Test\CTXSampleOut.txt", OK+NOERR)
File_Delete("\\Bisysftp\Test\CTXLineCount.txt", OK+NOERR)
if (File_Exist("\\Bisysftp\Test\MetConversion.txt")) {
File_Open("\\Bisysftp\Test\MetConversion.txt", OK)
#12=1 //counter
#13=Buf_Num //buffer# of the data file
Buf_Switch(Buf_Free) //find a empty buffer
File_Open_Write("\\Bisysftp\Test\CTXLineCount.txt",OVERWRITE)
#14=Buf_Num //buffer of the report file
Buf_Switch(#13) //switch to data file
Begin_Of_File() //move to beginning of file
#103=DI1(20,^` Metavante ACH Conversion v1.0`,
`Enter the Julian Date to search for using three numbers (Dates equal to or greater will be used for search).`,
`Example: 035 or 107.`,
`??Source:`,
`[&Ok]`,`[Cancel]`^,@(1),APP+CENTER,0,0)
while (! At_EOF) {
//Search("|<5200|*035",ERRBREAK) //This works
Search("|<5200|*Reg_Ins(#20)",ERRBREAK)
Block_Begin(Cur_Pos) //mark begining of block
#15=Cur_Line //remember the line#
Search("|N|<8200|*|N", ADVANCE)
Block_End(Cur_Pos) //mark end of block
Block_Save_As("\\Bisysftp\d$\Rpts\1137\ACH_Received\Converstion Testing\MetConvTst.txt", Block_Begin, Block_End, APPEND)
Block_Begin(CLEAR) //clear both the block-begin and block-end markers. (Any negative value clears the markers.)
Buf_Switch(#14) //switch to report
Ins_Text("CTX record: ")
Num_Ins(#12,FILL+NOCR+APPEND)
Ins_Text(", Line number:")
Num_Ins(#15,FILL)
Ins_Newline(1)
Alert( )
Buf_Switch(#13) //switch to data again
#12++ //increment counter by one
}
Buf_Close(OK+NOMSG) //close open buffer
Buf_Switch(#14) //switch to report
Buf_Close(OK+NOMSG) //close open buffer
}
Exit()

Another question:
Compare (r) The help manual says that the results will be {0,1,2} how can I write a "If results == 0 then do this"?
And I don't know what to replace "results" with for the If statement.

 


Topic: Can you use a Text register as part of a Search? (2 of 3), Read 13 times
Conf: Search and Replace
From: Howard Goldstein
Date: Sunday, March 08, 2009 10:28 AM

On 3/7/2009 10:21:13 PM, LeRoy Stevens wrote:
>I am trying to create a macro
>that will allow a user to
>input part of the search
>criteria (the 3 numbers in a
>line column 76, 77 and 78
>{sample line below}). I can
>get their input and place it
>in Text_Register 20 with the
>Dialog_Input command but I do
>not understand how to use that
>Text_Register.
>
>My search line:
>Search("|<5200|*Reg_Ins(#20)",
>ERRBREAK)
>
To search for the contents of Text Register 20, replace the REG_INS(#20) in your search line with the pattern |@(20) .

 


Topic: Re: Can you use a Text register as part of a Search? (3 of 3), Read 14 times
Conf: Search and Replace
From: Christian Ziemski
Date: Sunday, March 08, 2009 05:52 PM

On 08.03.2009 04:21 vtech-search-replace Listmanager wrote:
> From: "LeRoy Stevens"
>
> I only want the lines
> that have 035 in column 76, 77 and 78.

Perhaps something like this may help:

while (! At_EOF)
Search("|<5200",ERRBREAK)
Goto_Col(76)
if Match(@20)==0 {
// hit
}
}

> Another question:
> Compare (r) The help manual says that the results
> will be {0,1,2}
> how can I write a "If results == 0 then do this"?

Have a look at the example in the help manual.

Compare() returns the result:

#103 = Compare(..)
if ( #103 == 0) { ... }

Or shorter:

if ( Compare(..) == 0 ) { ... }