Hello and thanks in advance for any help here. I am working on a
script that is taking information from a database with no line breaks
and passing the information through this function that I have designed
to put line breaks in near a certain column size. The ultimate
destination for the text is a text file. When I run this code on a
piece of text with carriage returns already in it the function outputs
little boxes or NewLine control chars wherever a new line needs to
happen. Does anyone know of a way to get rid of those little boxes?

Thanks in advance,

-Jason


Function HardBreak(text, col)
Dim myArray(50)
lc = 0
Do Until Len(text) < col
If InStrRev(text, vbCr, col) Then
br = InStrRev(text, vbCr, col)
myArray(lc) = Mid(text, 1, br)
text = Mid(text, br + 1)
Else
If InStr(col - 6, text, " ") < col Then
br = InStr(col - 6, text, " ")
Else
br = InStrRev(text, " ", col)
End If
myArray(lc) = Mid(text, 1, br)
text = Mid(text, br + 1)
End If
lc = lc + 1
Loop
myArray(lc) = text
lc = 0
Do Until myArray(lc) = ""
If myArray(lc + 1) = "" Then
HardBreak = HardBreak & " " & myArray(lc)
Else
HardBreak = HardBreak & " " & myArray(lc) & vbNewLine
End If
lc = lc + 1
Loop
End Function

Re: little squares in output text by McKirahan

McKirahan
Mon Feb 09 20:27:48 CST 2004

"Jason" <jjanofsky@who.eop.gov> wrote in message
news:d6bf0053.0402091429.5fcd48f8@posting.google.com...
> Hello and thanks in advance for any help here. I am working on a
> script that is taking information from a database with no line breaks
> and passing the information through this function that I have designed
> to put line breaks in near a certain column size. The ultimate
> destination for the text is a text file. When I run this code on a
> piece of text with carriage returns already in it the function outputs
> little boxes or NewLine control chars wherever a new line needs to
> happen. Does anyone know of a way to get rid of those little boxes?
>
> Thanks in advance,
>
> -Jason
>
>
> Function HardBreak(text, col)
> Dim myArray(50)
> lc = 0
> Do Until Len(text) < col
> If InStrRev(text, vbCr, col) Then
> br = InStrRev(text, vbCr, col)
> myArray(lc) = Mid(text, 1, br)
> text = Mid(text, br + 1)
> Else
> If InStr(col - 6, text, " ") < col Then
> br = InStr(col - 6, text, " ")
> Else
> br = InStrRev(text, " ", col)
> End If
> myArray(lc) = Mid(text, 1, br)
> text = Mid(text, br + 1)
> End If
> lc = lc + 1
> Loop
> myArray(lc) = text
> lc = 0
> Do Until myArray(lc) = ""
> If myArray(lc + 1) = "" Then
> HardBreak = HardBreak & " " & myArray(lc)
> Else
> HardBreak = HardBreak & " " & myArray(lc) & vbNewLine
> End If
> lc = lc + 1
> Loop
> End Function

text = Replace(text,vbCrLf,"")



Re: little squares in output text by jjanofsky

jjanofsky
Tue Feb 10 07:15:07 CST 2004

Unfortunately the replace function does not work for me. The little
squares simply do not go away. Try putting in two paragraphs, with a
one line space between, into a text file and running that function and
you will see what I mean.

Thanks for any additional help,
-Jason



"McKirahan" <News@McKirahan.com> wrote in message news:<EkXVb.12818$032.51567@attbi_s53>...
> "Jason" <jjanofsky@who.eop.gov> wrote in message
> news:d6bf0053.0402091429.5fcd48f8@posting.google.com...
> > Hello and thanks in advance for any help here. I am working on a
> > script that is taking information from a database with no line breaks
> > and passing the information through this function that I have designed
> > to put line breaks in near a certain column size. The ultimate
> > destination for the text is a text file. When I run this code on a
> > piece of text with carriage returns already in it the function outputs
> > little boxes or NewLine control chars wherever a new line needs to
> > happen. Does anyone know of a way to get rid of those little boxes?
> >
> > Thanks in advance,
> >
> > -Jason
> >
> >
> > Function HardBreak(text, col)
> > Dim myArray(50)
> > lc = 0
> > Do Until Len(text) < col
> > If InStrRev(text, vbCr, col) Then
> > br = InStrRev(text, vbCr, col)
> > myArray(lc) = Mid(text, 1, br)
> > text = Mid(text, br + 1)
> > Else
> > If InStr(col - 6, text, " ") < col Then
> > br = InStr(col - 6, text, " ")
> > Else
> > br = InStrRev(text, " ", col)
> > End If
> > myArray(lc) = Mid(text, 1, br)
> > text = Mid(text, br + 1)
> > End If
> > lc = lc + 1
> > Loop
> > myArray(lc) = text
> > lc = 0
> > Do Until myArray(lc) = ""
> > If myArray(lc + 1) = "" Then
> > HardBreak = HardBreak & " " & myArray(lc)
> > Else
> > HardBreak = HardBreak & " " & myArray(lc) & vbNewLine
> > End If
> > lc = lc + 1
> > Loop
> > End Function
>
> text = Replace(text,vbCrLf,"")

Re: little squares in output text by McKirahan

McKirahan
Tue Feb 10 08:55:01 CST 2004

"Jason" <jjanofsky@who.eop.gov> wrote in message
news:d6bf0053.0402100515.484580b6@posting.google.com...
> Unfortunately the replace function does not work for me. The little
> squares simply do not go away. Try putting in two paragraphs, with a
> one line space between, into a text file and running that function and
> you will see what I mean.
>
> Thanks for any additional help,
> -Jason

Replace should work; you just have to figure out what the character(s)
is/are that need to be replaced.

Perhaps it just a single Carriage Return or Line Feed; try
text = Replace(text,vbCr,"")
or
text = Replace(text,vbLf,"")



Re: little squares in output text by Tom

Tom
Tue Feb 10 15:00:00 CST 2004

I use this approach ...

' Clean incorrectly formed line ends
' Drag and Drop file(s) to be cleaned onto this script
' or a shortcut pointing to this script on the desktop
' or in the 'Sendto' folder for right-click access.
'
with createobject("scripting.filesystemobject")
For each fn in wscript.arguments
s = .opentextfile(fn, 1).readall
s = replace(s, vbNewLine, "||")
s = replace(s, vbLf & vbCr, "||")
s = replace(s, vbLf, "||")
s = replace(s, vbCr, "||")
s = replace(s, "||", vbNewLine)
.opentextfile(fn, 2).write s
Next ' fn
End with ' fso

Tom Lavedas
===========
>-----Original Message-----
>"Jason" <jjanofsky@who.eop.gov> wrote in message
>news:d6bf0053.0402100515.484580b6@posting.google.com...
>> Unfortunately the replace function does not work for
me. The little
>> squares simply do not go away. Try putting in two
paragraphs, with a
>> one line space between, into a text file and running
that function and
>> you will see what I mean.
>>
>> Thanks for any additional help,
>> -Jason
>
>Replace should work; you just have to figure out what the
character(s)
>is/are that need to be replaced.
>
>Perhaps it just a single Carriage Return or Line Feed; try
> text = Replace(text,vbCr,"")
>or
> text = Replace(text,vbLf,"")
>
>
>.
>