Topic: (newbie here) removing newline control character (1 of 6), Read 25 times
Conf: Basic editing, Block operations
From: George Keller
Date: Saturday, January 08, 2011 07:35 PM

I am capturing data via Hyperterminal. I can not count on the technicians to uncheck the box to wrap the text if it exceeds the terminal width. Consequently my records are wrapped. I can remove the new line special characters from the file but I want to accomplish this only if the new line character is at the end of the line and not at the beginning of the line. The record ends when there are two new line characters. If I set up the search criteria with only 1 new line character, all the new line characters are removed. If I set up the search criteria for 2 new line characters it does exactly that and doesn't remove the ones I need removed.
In other words this is what if want to do:

If the 1st character of a line is a new line character, leave it there.

If the last character of a line is a new line character, delete it.

Since the end of the record is identified by 2 new line characters, I will then have the record on one line. Total characters for a record as less the 256 characters and are dlimited by spaces.

 


Topic: (newbie here) removing newline control character (2 of 6), Read 21 times
Conf: Basic editing, Block operations
From: Peter Rejto
Date: Saturday, January 08, 2011 09:11 PM

On 1/8/2011 7:35:06 PM, George Keller wrote:
>
> I can
>remove the new line special
>characters from the file but I
>want to accomplish this only
>if the new line character is
>at the end of the line and not
>at the beginning of the line.
>The record ends when there are
>two new line characters. If I
>set up the search criteria
>with only 1 new line
>character, all the new line
>characters are removed. If I
>set up the search criteria for
>2 new line characters it does
>exactly that and doesn't
>remove the ones I need
>removed.
>In other words this is what if
>want to do:
>

>
>If the last character of a
>line is a new line character,
>delete it.
>

Hi,


I do not know the answer to your question.
All I know is how I would try to get an answer:


Specifically, I would experiment with the Vedit

Cur_Char


command. This is that I found in the Vedit Macro Manual:


Cur_Char(BOL_Pos-Cur_Pos)

Return the value of the character at
the beginning of the current line.



First, I would replace BOL by EOL in this Example.
Second, I would experiment with the Vedit if command.
I do hope that the if command does reduce the problem to the previously solved one. That is to say, to delete the character if it is a new line character.

Good luck and please keep me posted.


-peter

 


Topic: Re: (newbie here) removing newline control character (3 of 6), Read 25 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Sunday, January 09, 2011 04:37 PM

On 09.01.2011 01:35 vtech-basic Listmanager wrote:
> From: "George Keller"
> I am capturing data via Hyperterminal.
> I can not count on the technicians to uncheck the box to
> wrap the text if it exceeds the terminal width. Consequently my records
> are wrapped. I can remove the new line special characters from the file
> but I want to accomplish this only if the new line character is at the
> end of the line and not at the beginning of the line. The record ends
> when there are two new line characters. If I set up the search criteria
> with only 1 new line character, all the new line characters are removed.
> If I set up the search criteria for 2 new line characters it does
> exactly that and doesn't remove the ones I need removed.
> In other words this is what if want to do:
>
> If the 1st character of a line is a new line character, leave it there.
>
> If the last character of a line is a new line character, delete it.
>
> Since the end of the record is identified by 2 new line characters, I
> will then have the record on one line. Total characters for a record as
> less the 256 characters and are dlimited by spaces.


So you want to convert something like:

wrapped long line 1[NL]
still line 1[NL]
[NL]
another wrapped long line 2[NL]
and still line 2[NL]
[NL]

to:

wrapped long line 1 still line 1[NL]
[NL]
another wrapped long line 2 and still line 2[NL]
[NL]


There may be an easier solution by using search+replace,
but the following macro does it too:



Begin_Of_File // start at beginning
while(! At_EoF){ // check complete file
End_Of_Line
Line(1, ERRBREAK) // next line ...
if (Match("|L") != 0){ // ... is not an empty one (is a cont. line)
Del_Char(-Chars_Matched) // delete preceeding NewLine char(s)
// Ins_Text(" ") // and (optionally) insert a space or so
}else{ // ... else is an end-of-record
Line(1, ERRBREAK) // leave it alone
}
}


Christian

 


Topic: Re: (newbie here) removing newline control character (4 of 6), Read 22 times
Conf: Basic editing, Block operations
From: George Keller
Date: Sunday, January 09, 2011 03:04 PM

Actually I want to convert it to this format:

wrapped long line 1 still line 1[NL]
another wrapped long line 2 and still line 2[NL]

I don't need a NL between each record. The fields within the records are delimited by spaces. Any given wrapped line may have as many as 3 lines.

Really appreciate the help.

 


Topic: Re: (newbie here) removing newline control character (5 of 6), Read 24 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Sunday, January 09, 2011 04:36 PM

On 09.01.2011 21:04 "George Keller" wrote:
>
> I don't need a NL between each record. The fields within
> the records are delimited by spaces. Any given wrapped
> line may have as many as 3 lines.

O.k.

So from this:

wrapped long line 1[NL]
still line 1[NL]
[NL]
another wrapped long line 2[NL]
and still line 2[NL]
[NL]

to:

wrapped long line 1 still line 1[NL]
another wrapped long line 2 and still line 2[NL]


... only one line needs to be changed in the macro:


Begin_Of_File
while(! At_EoF){ // check complete file
End_Of_Line
Line(1, ERRBREAK) // next line ...
if (Match("|L") != 0){ // ... is not an empty one (is a cont. line)
Del_Char(-Chars_Matched) // delete preceeding NewLine char(s)
Ins_Text(" ") // and (optionally) insert a space
}else{ // ... else is an end-of-record ...
Del_Line(1) // delete this empty line
}
}


-------------------

The same could be done by two "simple" Search+Replace, in a macro or
manually:

// Unwrap wrapped lines
Replace("([^\N])\N([^\N])", "\1 \2", REGEXP+BEGIN+ALL+NOERR)
//
// Remove remaining empty lines
Replace("|L|L", "|N", BEGIN+ALL+NOERR)


Christian

 


Topic: Re: (newbie here) removing newline control character (6 of 6), Read 16 times
Conf: Basic editing, Block operations
From: Ian Binnie
Date: Sunday, January 09, 2011 06:55 PM

The inbuilt "Convert Para to 1 line" should do this.

Just highlight the whole file, and run the command.