Topic: deleting certain newlines (1 of 15), Read 37 times
Conf: VEDIT Macro Language Support
From: Paul Breen
Date: Friday, November 04, 2005 12:53 AM

I have a file which has more newlines than it should
have. If a line begins with a number, it is OK. If the
line begins with a character, I want to concatenate
that line with the line preceeding it, until all lines
in the file begin with a number. I need to do this
hundreds, even thousands of times so I want to write a
macro. If you have anything close to this as an example,
I should be able to modify it. I'm used to PowerBasic
string functions.

Vedit est optime. CodeWright est mortuus.

 


Topic: deleting certain newlines (2 of 15), Read 27 times
Conf: VEDIT Macro Language Support
From: Ian Binnie
Date: Friday, November 04, 2005 01:25 AM

On 11/4/2005 12:53:30 AM, Paul Breen wrote:
>If the
>line begins with a character,
>I want to concatenate
>that line with the line
>preceeding it, until all lines
>in the file begin with a
>number.

Try:-
REPEAT(ALL)
{
Search("|<|!|D",ERRBREAK)
Del_Char(1)
}

 


Topic: deleting certain newlines (3 of 15), Read 29 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, November 04, 2005 02:42 AM

On 11/4/2005 12:53:30 AM, Paul Breen wrote:
>I have a file which has more newlines than it should
>have. If a line begins with a number, it is OK. If the
>line begins with a character, I want to concatenate
>that line with the line preceeding it, until all lines
>in the file begin with a number.

Ian's example seems to delete too much characters (as far as I understood the task).

I would suggest:


BeginOfFile
// special handling if first line begins without a number
// (has to be defined, now: do nothing)
//
if (Match("|D") != 0) {
Line(1, NOERR)
}

repeat(ALL)
{
Search("|<|!|D",ERRBREAK) // search line beginning without a number
Del_Char(-Newline_Chars) // concatenate by deleting previous line's CR/LF
Ins_Text(" ") // insert a space as delimiter, if wished
}


Christian

 


Topic: deleting certain newlines (4 of 15), Read 28 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, November 04, 2005 02:53 AM

>BeginOfFile
>// special handling if first line begins without a number
>// (has to be defined, now: do nothing)
>//
>if (Match("|D") != 0) {
> Line(1, NOERR)
>}
>repeat(ALL)
>{
>Search("|<|!|D",ERRBREAK) // search line beginning without a number
>Del_Char(-Newline_Chars) // concatenate by deleting previous line's CR/LF
>Ins_Text(" ") // insert a space as delimiter, if wished
>}

Or "a bit" shorter all in one call:

Replace("\N{[^0-9]}", " \1", REGEXP+BEGIN+ALL+NOERR)


Christian

 


Topic: deleting certain newlines (5 of 15), Read 25 times
Conf: VEDIT Macro Language Support
From: Paul Breen
Date: Friday, November 04, 2005 09:30 PM

Thanks Ian and Christian. I only ran the "long" version tonight and it ran like a champ. It ran so fast I did not see the screen blink. I thought I had done something wrong until I realized the screen had changed - it was done! I've been using a different editor that is a lot slower. I'm thinking about loading a really large data file to test the speed difference.

Vedit est optime. CodeWright est mortuus.

 


Topic: deleting certain newlines (6 of 15), Read 22 times
Conf: VEDIT Macro Language Support
From: Ian Binnie
Date: Saturday, November 05, 2005 07:05 PM

On 11/4/2005 2:42:33 AM, Christian Ziemski wrote:
Christian,

I agree Del_Char(Newline_Chars) looks better
I have always found Del_Char(1) works, and reliably deletes newlines.

>repeat(ALL)
>{
>Search("|<|!|D",ERRBREAK) // search
>line beginning without a number
>Del_Char(-Newline_Chars) //
>concatenate by deleting previous line's
>CR/LF
>Ins_Text(" ") // insert a
>space as delimiter, if wished
>}

I was concerned at the "-" in your code below.

Del_Char() wouldn't seem to support negative arguments, but it works - I guess Vedit ignores the sign.

 


Topic: Re: deleting certain newlines (7 of 15), Read 23 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Saturday, November 05, 2005 07:21 PM

At 07:06 PM 11/5/2005, you wrote:
>>Del_Char(-Newline_Chars) //
>
>I was concerned at the "-" in your code below.
>
>Del_Char() wouldn't seem to support negative arguments, but it works - I guess Vedit ignores the sign.

Incorrect, the "-" indicates it is deleting preceeding characters.

Ted.

 


Topic: Re: deleting certain newlines (9 of 15), Read 23 times
Conf: VEDIT Macro Language Support
From: Ian Binnie
Date: Sunday, November 06, 2005 06:37 PM

On 11/5/2005 7:21:55 PM, Ted Green wrote:
>At 07:06 PM 11/5/2005, you
>wrote:
>>>Del_Char(-Newline_Chars) //
>>
>>I was concerned at the "-" in your code below.
>>
>>Del_Char() wouldn't seem to support negative arguments, but it works - I guess Vedit ignores the sign.
>
>Incorrect, the "-" indicates
>it is deleting preceeding
>characters.
>
>Ted.
>

I thought this may be the case, but the Online help states:-
Del_Char(m) Delete 'm' characters, starting at the edit position.

I have just tested it and it works, and of course is documented in the Macro Manual.

 


Topic: Re: deleting certain newlines (11 of 15), Read 23 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Sunday, November 06, 2005 11:57 PM

At 06:38 PM 11/6/2005, you wrote:
>I thought this may be the case, but the Online help states:-
>Del_Char(m) Delete 'm' characters, starting at the edit position.

Sorry for the terseness, but 'm' is defined as a positive or negative number, with negative indicating backwards in the file.

'n' is defined as a positive-only number.

Ted.

 


Topic: Re: deleting certain newlines (8 of 15), Read 25 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Sunday, November 06, 2005 01:50 AM

On Sat, 05 Nov 2005 19:05:00 -0500, Ian Binnie wrote:
>
>I agree Del_Char(Newline_Chars) looks better
>I have always found Del_Char(1) works, and reliably deletes newlines.

Ian:

Del_Char(1) only delete complete newlines when editing text with file
type 1(LF) or 2(CR).
But under DOS/Windows the file type usually is 0(CR+LF).
And I can't see how Del_Char(1) should be able to delete those two
bytes.
Or am I overlooking something?

Christian

 


Topic: Re: deleting certain newlines (10 of 15), Read 23 times
Conf: VEDIT Macro Language Support
From: Ian Binnie
Date: Sunday, November 06, 2005 06:46 PM

On 11/6/2005 1:50:54 AM, Christian Ziemski wrote:
>On Sat, 05 Nov 2005 19:05:00 -0500, Ian
>Binnie wrote:
>>
>>I agree Del_Char(Newline_Chars) looks better
>>I have always found Del_Char(1) works, and reliably deletes newlines.
>
>Ian:
>
>Del_Char(1) only delete complete
>newlines when editing text with file
>type 1(LF) or 2(CR).
>But under DOS/Windows the file type
>usually is 0(CR+LF).
>And I can't see how Del_Char(1) should
>be able to delete those two
>bytes.
>Or am I overlooking something?
>
>Christian

No you are correct.
I must have been using a Unix file. (I have a lot of c files on my computer - Vedit hides the format, so you have to explicitly look to determine type.)

In Visual mode Del deletes the CR/LF pair, which is part of my confusion.

I have learned 2 new techniques for Vedit.

 


Topic: Re: deleting certain newlines (14 of 15), Read 23 times
Conf: VEDIT Macro Language Support
From: Paul Breen
Date: Friday, November 11, 2005 01:44 PM

This macro (the multi line ver) works on small files but on large files Vedit is forced to close and I lose all changes. I don't why the size of the file should cause this. I've been forced to write the utility in PowerBasic but I could have done that without buying vedit.
Any ideas on how to track this down?

Vedit est optime. CodeWright est mortuus.

 


Topic: Re: deleting certain newlines (15 of 15), Read 23 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, November 11, 2005 01:52 PM

On Fri, 11 Nov 2005 13:44:00 -0500, Paul Breen wrote:

>This macro (the multi line ver) works on small files but
>on large files Vedit is forced to close and I lose all changes.

What do you mean with "is forced to close"?

 


Topic: deleting certain newlines (12 of 15), Read 19 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Monday, November 07, 2005 02:25 PM

> Vedit est optime. CodeWright est mortuus.

I like your new slogan. Let's debug it a bit:

Vedit optimum est, decessit CW.

Or in a more general and ecclesiastiological fashon:

Vivat Vedit.
Si quis alio utitur programmate anathema sit.

("Long live Vedit.
Whoever uses any other program will be excommunicated.")

Cheers,

Fritz

 


Topic: Re: deleting certain newlines (13 of 15), Read 18 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Monday, November 07, 2005 04:40 PM

On Mon, 07 Nov 2005 14:25:00 -0500, Fritz Heberlein wrote:

>> Vedit est optime. CodeWright est mortuus.
>
>I like your new slogan. Let's debug it a bit:
>
>Vedit optimum est, decessit CW.
>
>Or in a more general and ecclesiastiological fashon:
>
>Vivat Vedit.
>Si quis alio utitur programmate anathema sit.

Ooh, my "Big Latinum" is too long ago.

>("Long live Vedit.
>Whoever uses any other program will be excommunicated.")

Ah, thanks! ;-)


Christian