Topic: REM-LINE.VDM modified for long lines (1 of 10), Read 25 times, 1 File Attachment
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Tuesday, April 20, 2004 02:13 AM

I modified REM-LINE.VDM for long lines.
The supplied macro ignores lines longer than 250 characters due to limitations of Search to 260 characters.

The modified macro considers lines match if first 250 characters are identical.
(I did contemplate splitting the lines into groups, and matching each, but did not think the extra effort necessary.)

Note a Visual search produces an error message "SEARCH/REPLACE STRING TOO LONG" if the string exceeds 260 characters.
I am not sure what if any error is expected from the Search() macro, it just seems to return not found.

 
REM-LINE.VDM (5KB)

 


Topic: Re: REM-LINE.VDM modified for long lines (2 of 10), Read 29 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Tuesday, April 20, 2004 03:39 PM

At 02:14 AM 4/20/2004, you wrote:
>I modified REM-LINE.VDM for long lines.
>The supplied macro ignores lines longer than 250 characters due to limitations of Search to 260 characters.
>
>The modified macro considers lines match if first 250 characters are identical.
>(I did contemplate splitting the lines into groups, and matching each, but did not think the extra effort necessary.)

Thank you for the modified macro. While it is fine to have this variation on this Forum where it is also documented, I prefer not to release it since its behaviour might be unexpected.

>Note a Visual search produces an error message "SEARCH/REPLACE STRING TOO LONG" if the string exceeds 260 characters.
>I am not sure what if any error is expected from the Search() macro, it just seems to return not found.

Actually the Search() command itself generates the error message.

The best way to handle extremely long search strings would be to search for e.g. the first 100 characters and then check the entire string with the Compare() command. (Obviously I am skipping some details.)

Ted.

 


Topic: Re: REM-LINE.VDM modified for long lines (3 of 10), Read 34 times
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Tuesday, April 20, 2004 08:35 PM

>Thank you for the modified
>macro. While it is fine to
>have this variation on this
>Forum where it is also
>documented, I prefer not to
>release it since its behaviour
>might be unexpected.
>
>>Note a Visual search produces an error message "SEARCH/REPLACE STRING TOO LONG" if the string exceeds 260 characters.
>>I am not sure what if any error is expected from the Search() macro, it just seems to return not found.
>
>Actually the Search() command
>itself generates the error
>message.
>
>The best way to handle
>extremely long search strings
>would be to search for e.g.
>the first 100 characters and
>then check the entire string
>with the Compare() command.
>(Obviously I am skipping some
>details.)
>
>Ted.
>
Since posting my comments, I have determined that the existing macro terminates prematurely when it encounters a long line.

Thanks for the hint, I will modify to use Compare() or Match(). I had not realised the length limitations did not apply to Compare().

 


Topic: Re: REM-LINE.VDM modified for long lines (5 of 10), Read 36 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Wednesday, April 21, 2004 09:13 AM

At 08:35 PM 4/20/2004, you wrote:
>Thanks for the hint, I will modify to use Compare() or Match(). I had not realised the length limitations did not apply to Compare().

Just to be complete - the Match() command also has the 256 char limit. However Compare() has no limit; when comparing buffers, entire huge files can be compared.

I noticed that the on-line help for Compare() was unclear; I have rewritten it to say:

Compare(r) Compare the text at the edit position with T-Reg 'r'.
This is a byte-by-byte comparison without Pattern
matching or Regular expressions. The comparison is
not case sensitive. Advances the edit position over
as many characters as matched.

Compare(b+BUFFER) Compare the text at the edit position with (a second)
edit buffer 'b'. The comparison starts at the edit
position in each edit buffer. This is a byte-by-byte
comparison without Pattern matching or Regular
expressions. The comparison is not case sensitive.
Advances the edit position over as many characters as
matched, in both edit buffers.

Ted.

 


Topic: Re: REM-LINE.VDM modified for long lines (7 of 10), Read 32 times, 1 File Attachment
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Wednesday, April 21, 2004 11:40 PM

On 4/21/2004 9:13:39 AM, Ted Green wrote:
>At 08:35 PM 4/20/2004, you
>wrote:
>Just to be complete - the
>Match() command also has the
>256 char limit. However
>Compare() has no limit; when
>comparing buffers, entire huge
>files can be compared.
>
>I noticed that the on-line
>help for Compare() was
>unclear; I have rewritten it

I have hopefully fixed the problem in my modified macro.
This now seems to reliably handle all cases.

I did not carefully check how the repeat loop worked in the original.

I am much happier with the result, and have learned some more about Vedit in the process.

 
REM-LINE(2).VDM (5KB)

 


Topic: Re: REM-LINE.VDM modified for long lines (8 of 10), Read 33 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Thursday, April 22, 2004 09:13 AM

At 11:40 PM 4/21/2004, you wrote:
>I have hopefully fixed the problem in my modified macro.
>This now seems to reliably handle all cases.

Thank you Ian. I saw the problem in your previous macro, but did not have time yesterday to fix it. I will check it carefully later today.

Ted.

 


Topic: Re: REM-LINE.VDM modified for long lines (9 of 10), Read 32 times, 1 File Attachment
Conf: VEDIT Macro Library
From: Ted Green
Date: Thursday, April 22, 2004 04:52 PM

At 11:40 PM 4/21/2004, you wrote:
>I have hopefully fixed the problem in my modified macro.
>This now seems to reliably handle all cases.

Your macro only worked if the remove-strings matched entire lines, which was not the intention. The original macro required that the remove-strings match at the beginning of the lines, which was also not the intention.

The attached macro should be correct, although I have not extensively tested all cases. The remove strings can match any portion of a line, and the remove strings can now be arbitrarily long.

Thank you again for your work on improving this macro.

Ted.

 
REM-LINE(3).VDM (5KB)

 


Topic: Re: REM-LINE.VDM modified for long lines (10 of 10), Read 34 times
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Friday, April 23, 2004 02:33 AM

On 4/22/2004 4:52:47 PM, Ted Green wrote:
>At 11:40 PM 4/21/2004, you
>wrote:

>Your macro only worked if the
>remove-strings matched entire
>lines, which was not the
>intention.

As this is what I wanted I will keep mine, under a different name.

I use this to maintain a list of downloaded files, to associate with URL.
I use Vedit to convert the XML downloads.rdf produced by Mozilla to a record to import into a database, and process it to ensure that only new entries are loaded.

 


Topic: Re: REM-LINE.VDM modified for long lines (4 of 10), Read 32 times, 1 File Attachment
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Tuesday, April 20, 2004 10:16 PM

On 4/20/2004 3:39:42 PM, Ted Green wrote:
>At 02:14 AM 4/20/2004, you
>wrote:
>Thank you for the modified
>macro. While it is fine to
>have this variation on this
>Forum where it is also
>documented, I prefer not to
>release it since its behaviour
>might be unexpected.
>
>The best way to handle
>extremely long search strings
>would be to search for e.g.
>the first 100 characters and
>then check the entire string
>with the Compare() command.
>(Obviously I am skipping some
>details.)
>
>Ted.
>
Thanks for the suggestion, I have modified the macro to check full long lines. This was easier than I anticipated.

The macro retains the original case insensitivity.

 
REM-LINE(1).VDM (5KB)

 


Topic: Re: REM-LINE.VDM modified for long lines (6 of 10), Read 35 times
Conf: VEDIT Macro Library
From: Ian Binnie
Date: Wednesday, April 21, 2004 09:41 PM

On 4/20/2004 10:16:08 PM, Ian Binnie wrote:

>Thanks for the suggestion, I have
>modified the macro to check full long
>lines. This was easier than I
>anticipated.
>
>The macro retains the original case
>insensitivity.
>
I think I may have rushed into publication with the above macro.

It does work, and would probably be OK for most real applications, but I realised that the line
If(Match("|L",ERRBREAK) == 0) //IB 21/04/2004 ensure at EOL
would cause a short line in the remove-list file which matched the start of a longer line would cause a potential match to be skipped.
It should be NOERR.

Mind you the original would cause this line to be incorrectly removed.

I need to think more about the loop. The following from the original is not an infinite loop, only because the line is removed.
Repeat(ALL) { //Search for all occurrences
Buf_Switch(#11) //Switch to the source file
Search("|<|@(15)|Y|L",BEGIN+ERRBREAK) //Search for matching line
RCB(0,CP,CP+Chars_Matched,DELETE) //Move line to T-Reg 0
Buf_Switch(#14) //Switch to "removed" lines buffer
Reg_Ins(0) //Add the "removed" line
}

A fix to the potential problem needs a change to the loop, which I had not appreciated.