Line Wrapping 
Author Message
 Line Wrapping

Being new to Clipper, I'm not yet up to par and I find myself in need of
a Clipper routine that will allow me to wrap long data lines, to 80 or
less bites.
The files I am being supplied are survey verbatim files and have record
lengths over 1000 bites in some cases.  I'm using a PC and the SAS
programming lang. to write reports on these data.  SAS has no procedure
to wrap lines.....help


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

Quote:

> Being new to Clipper, I'm not yet up to par and I find myself in need of a
> Clipper routine that will allow me to wrap long data lines, to 80 or less
> bites.

Have a look at MEMOLINE() in your Clipper manuals.

--
Take a look in Hagbard's World: |   w3ng - The WWW Norton Guide reader.
http://www.hagbard.demon.co.uk/ |     eg - Norton Guide reader for Linux.
http://www.acemake.com/hagbard/ |    weg - Norton Guide reader for Windows.
Free software, including........| dgscan - DGROUP scanner for Clipper.



Thu, 09 Jan 2003 03:00:00 GMT  
 Line Wrapping
On Sun, 23 Jul 2000 16:54:54 GMT, jay goddard

Quote:

> SAS has no procedure to wrap lines.....help

In SAS you can have a DATA step just before the step containing the
PUTs. In that step you can loop SUBSTRinging in chunks of 80 bytes
until the length of the string. Of course, you can make it more
sofisticated if you wrap at word delimiters (space, punctuation marks
etc)


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


Quote:
>Being new to Clipper, I'm not yet up to par and I find myself in need of
>a Clipper routine that will allow me to wrap long data lines, to 80 or
>less bites.
>The files I am being supplied are survey verbatim files and have record
>lengths over 1000 bites in some cases.  I'm using a PC and the SAS
>programming lang. to write reports on these data.  SAS has no procedure
>to wrap lines.....help

maybe this will help :

cData:=memoread("survey_file_name")
fp:=fcreate(output.dat)

for i=1 to mlcount(cData)  // Default line lenght is 79 and wordwraping is
on
    cString=memoline(cData,,i)
    fwrite(fp,cString+chr(13)+chr(10)
next

fclose(fp)

Jovo



Fri, 10 Jan 2003 03:00:00 GMT  
 Line Wrapping
Jovo,

Thank you very much for your help...it worked fine.....jay

Quote:


> >Being new to Clipper, I'm not yet up to par and I find myself in need of
> >a Clipper routine that will allow me to wrap long data lines, to 80 or
> >less bites.
> >The files I am being supplied are survey verbatim files and have record
> >lengths over 1000 bites in some cases.  I'm using a PC and the SAS
> >programming lang. to write reports on these data.  SAS has no procedure
> >to wrap lines.....help

> maybe this will help :

> cData:=memoread("survey_file_name")
> fp:=fcreate(output.dat)

> for i=1 to mlcount(cData)  // Default line lenght is 79 and wordwraping is
> on
>     cString=memoline(cData,,i)
>     fwrite(fp,cString+chr(13)+chr(10)
> next

> fclose(fp)

> Jovo



Sat, 11 Jan 2003 03:00:00 GMT  
 Line Wrapping
Understand breaking lines in the input statement but I need to actually
break at words but thanks anyway.......jay
Quote:

> On Sun, 23 Jul 2000 16:54:54 GMT, jay goddard

> > SAS has no procedure to wrap lines.....help

> In SAS you can have a DATA step just before the step containing the
> PUTs. In that step you can loop SUBSTRinging in chunks of 80 bytes
> until the length of the string. Of course, you can make it more
> sofisticated if you wrap at word delimiters (space, punctuation marks
> etc)



Sat, 11 Jan 2003 03:00:00 GMT  
 Line Wrapping
Hi Jay.
This is a small prg that you can use to break a file in fixed lenght lines:

parameters cIn, cOut, cTamanho

? "STRIP"
if PCOUNT() != 3

   ? "Extracts data from files created with other languages (basic etc),"
   ? "who have fixed lenght records (without a header record)"
   ?
   ? " Usage:  STRIP  InputFile OutPutFile LenghtOfRecord"
   ?
   ? "OutPutFile will have all records separated by a CR"
   ? "NOTE: Replaces all chr(0) and chr(255) with a space."

   return
endif
nH := fopen(cIn)
if nh < 1
   ? "error "+cIn
   return
endif

cBuffer := space(VAL(cTamanho))
if file(cout)
   ? cout +" exists.Canceled"
   return
endif
nO := FCREATE( cOut)
if no < 1
   ?" error "+cout
   return
endif

while .y.

   cBuffer := STRTRAN(cBuffer, CHR(255), " ")
   cBuffer := STRTRAN(cBuffer, CHR(0), " ")

   fWrite( no, cBuffer+CHR(13))
   if nBytes < LEN(cBuffer)
      exit
   endif
enddo
?"end of file or error."

Regards from Portugal
Antnio Vila-Ch?


Quote:
>Being new to Clipper, I'm not yet up to par and I find myself in need of
>a Clipper routine that will allow me to wrap long data lines, to 80 or
>less bites.
>The files I am being supplied are survey verbatim files and have record
>lengths over 1000 bites in some cases.  I'm using a PC and the SAS
>programming lang. to write reports on these data.  SAS has no procedure
>to wrap lines.....help



Sat, 11 Jan 2003 03:00:00 GMT  
 Line Wrapping
The solution with
memoread("survey_file_name")
is minimal and elegant.

However, memoread will fail if the size of survey_file_name is greater
that 65535 bytes (64k).  In practice the number is a bit smaller.  If
your input files may be larger, implement the fopen and fread approach.

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



Sat, 11 Jan 2003 03:00:00 GMT  
 Line Wrapping
I wrote a small bit of code to do this a while ago - it word-wrapped the
contents of 1 long character string onto multiple print lines on an
invoice - I'll take a dig around...

- Kevin.
___________________________________________

O||||O   Its a jeep thing - - You wouldn't understand...
()()


Quote:
> Understand breaking lines in the input statement but I need to actually
> break at words but thanks anyway.......jay


> > On Sun, 23 Jul 2000 16:54:54 GMT, jay goddard

> > > SAS has no procedure to wrap lines.....help

> > In SAS you can have a DATA step just before the step containing the
> > PUTs. In that step you can loop SUBSTRinging in chunks of 80 bytes
> > until the length of the string. Of course, you can make it more
> > sofisticated if you wrap at word delimiters (space, punctuation marks
> > etc)



Sun, 12 Jan 2003 03:00:00 GMT  
 Line Wrapping
Jay,

Hope this helps - its an in-memory solution for text up to the limit of text
string length and array size.

- Kevin
___________________________________________

O||||O   Its a jeep thing - - You wouldn't understand...
()()

// WordWraptext()
//  accepts single text string and returns array containing elements of
desired length
//  text word-wrapped. All array elements are space-padded to the specified
length.
//  Note - hyphens are not handled...

// Usage:

aText := WordWrapText( cText, nLineLength )

nLineCount := LEN( aText )

FOR Counter := 1 TO nLineCount
  ?? aText[ Counter ]
NEXT

FUNCTION WordWrapText ( cInText, nLength )
  // take passed text string and return word-wrapped array of text
  // with each line being <nlength> characters long
  LOCAL nCharCount  := LEN( cInText )
  LOCAL nStartPos   := 1
  LOCAL aWorkArray  := {}
  LOCAL nLineLength
  LOCAL nAddedLength
  LOCAL cWorkText

  DO WHILE nStartPos <= nCharCount

    // locate last space before end of line length
    // and extract characters up to the space
    // if none, use all characters
    nLineLength   := MIN( ( nCharCount - nStartPos ) + 1, nLength )
    cWorkText     := SUBSTR( cInText, nStartPos, nLineLength )
    cBoundaryText := SUBSTR( cInText, nStartPos + nLineLength - 1, 2 )

    // determine if a word crosses line boundary
    IF nLineLength == nLength .AND. LEN( cBoundaryText ) == 2 .AND. ;
    !( ' ' $ cBoundaryText )
      IF ( nAddedLength := RAT( ' ', cWorkText ) ) = 0
        nAddedLength := nLineLength
      ENDIF
    ELSE
      nAddedLength := nLineLength
    ENDIF

    // add extracted text to array
    AADD( aWorkArray, PADR( LTRIM( LEFT( cWorkText, nAddedLength ) ),
nLength ) )

    // increment start position
    nStartPos += nAddedLength
  ENDDO

RETURN aWorkArray


Quote:
> Understand breaking lines in the input statement but I need to actually
> break at words but thanks anyway.......jay


> > On Sun, 23 Jul 2000 16:54:54 GMT, jay goddard

> > > SAS has no procedure to wrap lines.....help

> > In SAS you can have a DATA step just before the step containing the
> > PUTs. In that step you can loop SUBSTRinging in chunks of 80 bytes
> > until the length of the string. Of course, you can make it more
> > sofisticated if you wrap at word delimiters (space, punctuation marks
> > etc)



Sun, 12 Jan 2003 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Line wrapping

2. Line wrapping in listboxes?

3. Edit field 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