Topic: Needs WILDFILE.INP with multiple S&R strings. (1 of 11), Read 91 times
Conf: Wildfile, Other macros
From: Peter Rejto
Date: Saturday, October 06, 2001 06:14 PM

Thanks Ted for the VEDIT + 6.00.1 WILDFILE.VDM macro.

Now, I would like to use it on a single file with multiple Search and Replacement strings.
I also would like to redirect the keyboard input to the file WILDFILE.INP.

I expect that this limiting case should be much easier to treat than the case of many files and a single pair of Search and Replacement strings treated by the macro.

I just do not know how to go about it.

Thanks,

-peter rejto

 


Topic: Re: Needs WILDFILE.INP with multiple S&R strings. (2 of 11), Read 81 times
Conf: Wildfile, Other macros
From: Christian Ziemski
Date: Sunday, October 07, 2001 03:25 AM

On Sat, 6 Oct 2001 18:15:38 -0400, you wrote:

>Now, I would like to use it on a single file with multiple Search and =Replacement strings.
>I also would like to redirect the keyboard input to the file =WILDFILE.INP.
>
>I expect that this limiting case should be much easier to treat than the= case of many files and a single pair of Search and Replacement strings =treated by the macro.
>
>I just do not know how to go about it.


wildFILE.vdm is for working on many FILEs (the name says this...).


You are looking for a wildREPLACE.vdm, I think.

Suggestion: Write it by yourself. It should be relatively easy.

1.) Do a loop with Dialog_Input()'s to type in
the search/replace strings.
2.) Collect these inputs with every line a surrounding
Replace("...","...",BEGIN+ALL+NOERR)
in a text register.
3.) Call this text register after the last input.

Done.



Christian

 


Topic: Re: Needs WILDFILE.INP with multiple S&R strings. (3 of 11), Read 83 times
Conf: Wildfile, Other macros
From: Christian Ziemski
Date: Sunday, October 07, 2001 03:41 AM

PS:

>1.) Do a loop with Dialog_Input()'s to type in
> the search/replace strings.
>2.) Collect these inputs with every line a surrounding
> Replace("...","...",BEGIN+ALL+NOERR)
> in a text register.
>3.) Call this text register after the last input.

or:

3.) Save that text register (with the Replace()'s) into
a new MYREPLACE1.VDM.
4.) Now you can call MYREPLACE1.VDM every time you want to
Search/Replace this way.
It's like a .INP file for your special usage now.


Christian

 


Topic: Progress report. (4 of 11), Read 75 times
Conf: Wildfile, Other macros
From: Peter Rejto
Date: Wednesday, October 10, 2001 12:50 PM

Christian,

Thanks for suggesting the new Dialog Input macro. I still have trouble with your "loop"
suggestion. However, I can treat 2 pairs of search and replace strings! I think that this is a really nice extension of the Vedit {Search, Replace} menu command. At the same time it illustrates the power of the new Dialog Input command. This is what I did:

DI1(5,"`WildS&R Macro (-Enter Search & Replace Strings`,
`\t\t\t\t\t\t\t`,
`??&Search string #1:`,
`??&Replace string #1:`,
`??&Search string #2:`,
`??&Replace string #2:`,
`[&Ok]`,`[&Cancel]`",
SCREEN+CENTER+SET,0,0)

:fixup:
Replace(@5,@6,BEGIN+ALL+NOERR)
Replace(@7,@8,BEGIN+ALL+NOERR)
//Replace("word3","fix3",BEGIN+ALL+NOERR)
//Replace("word4","fix4",BEGIN+ALL+NOERR)
//
// Add any additional Replace() commands.
//
Return()

Thanks again,

 


Topic: Re: Needs WILDFILE.INP with multiple S&R strings (5 of 11), Read 76 times
Conf: Wildfile, Other macros
From: Christian Ziemski
Date: Wednesday, October 10, 2001 03:08 PM

Peter,

here is my solution.
I wrote it in a few minutes and so it's not optimized, but it should
be able to show you the way.

Christian




Reg_Empty(99)

repeat(ALL){ // endless loop until [Done]

#98=DI1(5,"'WildS&R Macro','
Enter as many Search & Replace Strings as you want.
Then press [Done] to do the replace(s).

Or press to leave the macro without any action.
',
`??&Search string: `,
`??&Replace string:`,
`[&Next]`,`[&Done]`",
SCREEN+CENTER+SET,0,0)

if(#98==0){ return } // if ESC pressed exit without action
if(#98==2){ break } // if [Done] clicked end loop

Reg_Set(99, 'Replace("', APPEND)
Reg_Set(99, @5, APPEND)
Reg_Set(99, '","', APPEND)
Reg_Set(99, @6, APPEND)
Reg_Set(99, '", BEGIN+ALL+NOERR)', APPEND)
Reg_Set(99,'
', APPEND)
}

Call(99)

Return()

 


Topic: Re: Needs WILDFILE.INP with multiple S&R strings (6 of 11), Read 70 times
Conf: Wildfile, Other macros
From: Peter Rejto
Date: Thursday, October 11, 2001 01:03 PM

Thanks Christian,

What a nice surprise. I was going to give you my second progress report and I found your additional suggestions. I am appending my second progress report anyway.

I would like to number my search replacement strings and I would like to cut up the task as:

#1. Put the S&R strings into the text registers.

#2. Run the Search and Replace command.

So, I shall use a combination of your suggestions and my stuff:


//
:Step1:
//
#100=DI1(5,"`WildS&R Macro (-Enter Search & Replace Strings`,
`\t\t\t\t\t\t\t`,
`??&Search string #1:`,
`??&Replace string #1:`,
`??&Search string #2:`,
`??&Replace string #2:`,
`[&Ok]`,`[&Next]`,`[&Cancel]`, ",SET+APP+CENTER,0,0)
if (#100==2) {goto Step_2}

:fixup_1:
Replace(@5,@6,BEGIN+ALL+NOERR)
Replace(@7,@8,BEGIN+ALL+NOERR)
Return()
//
:Step_2:
//
#100=DI1(9,"`WildS&R Macro (-Enter Search & Replace Strings`,
`\t\t\t\t\t\t\t`,
`??&Search string #3:`,
`??&Replace string #3:`,
`??&Search string #4:`,
`??&Replace string #4:`,
`[&Ok]`,`[&Next]`,`[&Cancel]`, ",SET+APP+CENTER,0,0)
if (#100==2) {goto Step_3}
//

 


Topic: Thanks Christian. (7 of 11), Read 63 times
Conf: Wildfile, Other macros
From: Pauli Lindgren
Date: Thursday, October 18, 2001 04:05 AM

What is the purpose of all this?

So, you request several search and replace string pairs from user. After all the strings have been entered, you perform each search and replace one by one.

Why don't you just perform each replace immediately after the strings have been entered? What is the purpose of the delay?

If pressing Ctrl-F2 for each replacement is too much bother, why not just use a loop for that. Something like this:

Repeat (all) {
Dialog_Input_1(...)
If(cancel) break
Replace(...)
}

 


Topic: Thanks Christian. (8 of 11), Read 59 times
Conf: Wildfile, Other macros
From: Christian Ziemski
Date: Thursday, October 18, 2001 07:42 AM

>What is the purpose of all this?

Good question ;-)


>Why don't you just perform each replace immediately after
>the strings have been entered? What is the purpose of the delay?

1.) Think of a 2 GB file to search/replace. Every run would last some time and so the user has to wait every time.
The above way all strings are entered at once and the user is then able to take a coffee or so.

2.) The macro could be expanded to write the Replace commands to a VDM file. So it's possible to use the same replace orgy again and again without typing it again (maybe in conjunction with WILDFILE).


Christian

 


Topic: Thanks Christian. (9 of 11), Read 58 times
Conf: Wildfile, Other macros
From: Peter Rejto
Date: Tuesday, October 23, 2001 11:00 AM

Pauli,



Let me give you a more specific description of my problem. I number the equations in my manuscripts. My compiler, Latex is a very powerful program and it also numbers my equations in order.

So, I end up with two numbering systems. One is mine, the other is the one of Latex. If I look at the compiled manuscript I get the Latex numbering. If I look at the uncompiled manuscript I get my own numbering. Since I make the corrections in the uncompiled manuscript I need a dictionary.

Actually, Latex also makes such a dictionary
as a temporary file, .aux. Now, what I would like to do is to eliminate this dictionary by renumbering my equations as per Latex.

In short, I want a Vedit input file, since Latex does the work for me. I just would like to edit the Latex .aux file.

I hope that this makes sense to you. I also hope to hear from Christian Gerard, who also uses Latex for math manuscripts. I do not know how does he handle this proof reading issue.

Thanks,

-peter.

 


Topic: Thanks Christian. (10 of 11), Read 57 times
Conf: Wildfile, Other macros
From: Pauli Lindgren
Date: Monday, December 03, 2001 05:07 AM

Peter,

I see. You need to read the search and replacement strings from a file, rather than typing them from keyboard.

Here is a simple macro that does that:

// Multi Replace
// - Replace multiple strings. Read strings from file replace.lst.

#20 = Buf_Num // original buffer
#21 = Buf_Free // list of replacement strings

Buf_Switch(#21)
File_Open("replace.lst", NOMSG+OVERWRITE+NOEVENT)
BOF

repeat(ALL) {
#1 = CP
Search("|S", ERRBREAK)
RCB(10,#1,CP) // treg 10 = search string
Search("|!|S", ERRBREAK)
RCB(11,CP,EOL_pos) // treg 11 = replace string
Line(1)
Buf_Switch(#20) // switch to original buffer
BOF
Replace(@10, @11, ALL+NOERR)
Buf_Switch(#21) // switch to list of strings
}

Buf_Quit(OK)
Buf_Switch(#20)


It reads the search and replacement strings from the file "replace.lst" (you can change the name). Each line of replace.lst must contain two words: the first one is the search string, the second one is the replace string. Example:

1000 aaa
2000 bbb
2100 bcc
2200 bdd
3000 ccc

You could use comma or other special characters to separate the strings instead.
Also, you may need to do some more checking, in case the replace.lst file contains other lines or characters that need to be filtered out.

-- Pauli

 


Topic: Needs WILDFILE.INP with multiple S&R strings. (11 of 11), Read 54 times
Conf: Wildfile, Other macros
From: Bob Passmore
Date: Wednesday, December 05, 2001 10:23 AM

On 10/6/2001 6:14:00 PM, Peter Rejto wrote:
>Thanks Ted for the VEDIT +
>6.00.1 WILDFILE.VDM macro.
>
>Now, I would like to use it on
>a single file with multiple
>Search and Replacement
>strings.
>I also would like to redirect
>the keyboard input to the file
>WILDFILE.INP.
>

Peter: In addition to considering Pauli's suggestion, I invite you to look at the "batch search/replace" macro posted under "Vedit Macro Library on 11/27/2001. It also reads search/replace data from an input file, and treats strings that begin with letters or digits as words. I'd be interested to hear whether others find it useful.

Bob