Line wrapping 
Author Message
 Line wrapping

I am in need of routine that will allow me to specify lrecl of new file
being read from another file with an extended lrecl.  Also allow me to
specify names of both existing and new file.  Can anyone help???

Thanks very much....jay



Wed, 08 Jan 2003 03:00:00 GMT  
 Line wrapping


Quote:
>I am in need of routine that will allow me to specify lrecl of new file
>being read from another file with an extended lrecl.  Also allow me to
>specify names of both existing and new file.  Can anyone help???

Perhaps.

What is lrecl?  It isn't an awk (or unix) term I've heard of.

If you can tell us what you want done in words we understand, then
perhaps we can tell you how to do it with awk.

Showing what things would like before and after is very helpful
in explaining what wou want to do.

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Wed, 08 Jan 2003 03:00:00 GMT  
 Line wrapping


Quote:


>>I am in need of routine that will allow me to specify lrecl of new
>>file being read from another file with an extended lrecl.  Also allow
>>me to specify names of both existing and new file.  Can anyone help???

>Perhaps.

>What is lrecl?  It isn't an awk (or unix) term I've heard of.

<snip>

Maybe inapt, but LRECL is an IBM mainframe term meaning logical record
length. You've lived a blessed life if LRECL, JCL, DSN and DDN aren't
seared into your memory.

To the original poster: are you doing this on a mainframe? If so, would
you be using awk?? If so, then you should be able to read each record
from the file with the extended record length into awk's $0 and write
sequential substrings of specified maximum length to the new file with
the shorter record length. Presumably you'd want to leave words and
numbers intact, so you should split into substrings after the rightmost
whitespace character to the left of your output record length.

BEGIN { newlen = 72 }
{ s = $0
  do {
    ss = substr(s, 1, newlen)
    sub(/[^ \t]*$/, "", ss)
    printf("%-*s", newlen, ss)
    s = substr(s, length(ss))
  } while (length(s))

Quote:
}

It's been a while since I've done this, so I'm not sure I don't need to
include a newline (or EBCDIC equivalent) at the ends of the new records.

If you have a mainframe awk, you may have a mainframe version of unix's
fold command, which would be better suited to this task. Then, since
this isn't exactly an uncommon operation on mainframes, isn't there a
system command or standard REXX or CLIST script to do this?

If you're not on a mainframe, then odds are very good you have fold. Use
it to do this instead of awk.

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 08 Jan 2003 03:00:00 GMT  
 Line wrapping

Quote:
>     s = substr(s, length(ss))

Make that line

     s = substr(s, length(ss) + 1)

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 08 Jan 2003 03:00:00 GMT  
 Line wrapping

Quote:

> I am in need of routine that will allow me to specify lrecl of new file
> being read from another file with an extended lrecl. Also allow me to
> specify names of both existing and new file. Can anyone help???

Use dd(1).

--
Jim Monty

Tempe, Arizona USA



Wed, 08 Jan 2003 03:00:00 GMT  
 Line wrapping
Jim,

Sorry but I have no idea what you just said........jay

Quote:


> > I am in need of routine that will allow me to specify lrecl of new file
> > being read from another file with an extended lrecl. Also allow me to
> > specify names of both existing and new file. Can anyone help???

> Use dd(1).

> --
> Jim Monty

> Tempe, Arizona USA



Thu, 09 Jan 2003 03:00:00 GMT  
 Line wrapping
Harlan,

Thanks for the information.

As to application, I am writing reports from survey verbatum input files on
a PC, using SAS.

Thanks again.....jay

Quote:





> >>I am in need of routine that will allow me to specify lrecl of new
> >>file being read from another file with an extended lrecl.  Also allow
> >>me to specify names of both existing and new file.  Can anyone help???

> >Perhaps.

> >What is lrecl?  It isn't an awk (or unix) term I've heard of.

> <snip>

> Maybe inapt, but LRECL is an IBM mainframe term meaning logical record
> length. You've lived a blessed life if LRECL, JCL, DSN and DDN aren't
> seared into your memory.

> To the original poster: are you doing this on a mainframe? If so, would
> you be using awk?? If so, then you should be able to read each record
> from the file with the extended record length into awk's $0 and write
> sequential substrings of specified maximum length to the new file with
> the shorter record length. Presumably you'd want to leave words and
> numbers intact, so you should split into substrings after the rightmost
> whitespace character to the left of your output record length.

> BEGIN { newlen = 72 }
> { s = $0
>   do {
>     ss = substr(s, 1, newlen)
>     sub(/[^ \t]*$/, "", ss)
>     printf("%-*s", newlen, ss)
>     s = substr(s, length(ss))
>   } while (length(s))
> }

> It's been a while since I've done this, so I'm not sure I don't need to
> include a newline (or EBCDIC equivalent) at the ends of the new records.

> If you have a mainframe awk, you may have a mainframe version of unix's
> fold command, which would be better suited to this task. Then, since
> this isn't exactly an uncommon operation on mainframes, isn't there a
> system command or standard REXX or CLIST script to do this?

> If you're not on a mainframe, then odds are very good you have fold. Use
> it to do this instead of awk.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Thu, 09 Jan 2003 03:00:00 GMT  
 Line wrapping

Quote:



> > > I am in need of routine that will allow me to specify lrecl of new file
> > > being read from another file with an extended lrecl. Also allow me to
> > > specify names of both existing and new file. Can anyone help???

> > Use dd(1).

> Sorry but I have no idea what you just said........

I said, "Use dd(1)."

Why? Just a hunch, based on the morsel of information you posted
about your problem. dd is a utility that may or may not be readily
available to you, and may or may not be applicable to your problem.
There's no way for me to know.

See the dd(1) man page at URL <http://www.freebsd.org/cgi/man.cgi?
query=dd&sektion=1&apropos=0&manpath=FreeBSD+4.0-RELEASE%2fPorts>.

--
Jim Monty

Tempe, Arizona USA



Fri, 10 Jan 2003 03:00:00 GMT  
 Line wrapping


Quote:



>>>>I am in need of routine that will allow me to specify lrecl of new
>>>>file being read from another file with an extended lrecl. Also
>>>>allow me to specify names of both existing and new file. Can anyone
>>>>help???

>>> Use dd(1).

>> Sorry but I have no idea what you just said........

>I said, "Use dd(1)."

<snip>

Since the OP mentioned in another branch of this thread that this he's
trying to use awk in conjunction with SAS, I'm guessing his unix
background is slight to nonexistent. So "Use dd(1)" would have been as
helpful as unicode Mandarin rendered as ASCII. There are a few awks that
don't come with a full set of unix-like tools, so it's not appropriate
to take unix familiarity for granted.

For the OP: dd(1) refers to unix's/POSIX's dd command (the '(1)' means
it's in the manual's first section). This command allows users to run
low-level device I/O tasks. One of the things it can do is handle
different input and output block sizes. However, if the input file in
question is plain text, then dd can do stupid things when words or
numbers span output block boundaries. For variable length plain text
records, the unix/POSIX fold command will usually do a better job.

No doubt I'll be accused of pedantry.

Sent via Deja.com http://www.deja.com/
Before you buy.



Fri, 10 Jan 2003 03:00:00 GMT  
 Line wrapping
Harlan,

You have uncanny insight into the problem.  I've just recently received a
book on AWK, suggesting I might find it helpful.  Well........
Again, UNIX is no BIG BLUE or P.C. so my knowledge is very limited where it
is concerned.

Your explanation was very helpful in abling me to make a decision as to how
to proceed.  Writing a routine in Clipper or C++ will be alot more
productive to the end result of having a parameter driven command line
utility.  I was simply looking for an AWK program to wrap lines and allowing
the passing of parameters (filein, fileout, lrecl) from the command line.  I
felt that it would give me a more immediate understanding of the AWK
language.

Maybe you could suggest a GOOD reference of  tools/templetes for AWK.  Any
help would be appreciated.

Thank you again for your help..........jay

Quote:






> >>>>I am in need of routine that will allow me to specify lrecl of new
> >>>>file being read from another file with an extended lrecl. Also
> >>>>allow me to specify names of both existing and new file. Can anyone
> >>>>help???

> >>> Use dd(1).

> >> Sorry but I have no idea what you just said........

> >I said, "Use dd(1)."

> <snip>

> Since the OP mentioned in another branch of this thread that this he's
> trying to use awk in conjunction with SAS, I'm guessing his unix
> background is slight to nonexistent. So "Use dd(1)" would have been as
> helpful as unicode Mandarin rendered as ASCII. There are a few awks that
> don't come with a full set of unix-like tools, so it's not appropriate
> to take unix familiarity for granted.

> For the OP: dd(1) refers to unix's/POSIX's dd command (the '(1)' means
> it's in the manual's first section). This command allows users to run
> low-level device I/O tasks. One of the things it can do is handle
> different input and output block sizes. However, if the input file in
> question is plain text, then dd can do stupid things when words or
> numbers span output block boundaries. For variable length plain text
> records, the unix/POSIX fold command will usually do a better job.

> No doubt I'll be accused of pedantry.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 11 Jan 2003 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Line wrapping in listboxes?

2. Edit field line wrapping

3. Line Wrapping

4. Line-wrap test

5. disable line wrap in xterm??

6. How to do line wrapping?

7. line wrapping in news messages

8. line wrapping (was: Re: What exactly is multi-user?)

9. Wrapping long lines

10. Recognizing wrapped lines

11. Scrolling wrapped lines

12. textbox scrolling malfunctions with wrapped lines

 

 
Powered by phpBB® Forum Software