0
ASP VBSCRIPT: for a declared string, inserting a line break every N characters
LEGEND
,
/t5/dreamweaver-discussions/asp-vbscript-for-a-declared-string-inserting-a-line-break-every-n-characters/td-p/844675
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
I'm using ASP VB. I want to insert a VbCr or a VbLf into a
declared string
every N characters. FWIW, I want to do this because of an apparent
limitation in MSXML2, which I am using to "scrape" data from webpages that I
control: I'm getting spurious exclamation points (!) where line lengths are
too long. Manually inserting line breaks (which do not render in HTML) seems
to solve the problem. Can someone tell me how to do this?
Put another way, I need to flesh out the following pseudocode:
Dim myString, myCursorPosition, myIncrement
myString ="The quick brown fox jumped over the lazy dog."
myCurrentCursorPosition=0
myIncrement=5 ' I want a line break for every myIncrement
While [there are still remaining characters to walk through in the string
' navigate cursor by myIncrement through myString
...
' insert a VbLf at myCurrentCursorPosition
...
myCurrentCursorPosition = myCurrentCursorPosition + myIncrement
[loop]
Thanks for any help on the syntax here.
-KF
every N characters. FWIW, I want to do this because of an apparent
limitation in MSXML2, which I am using to "scrape" data from webpages that I
control: I'm getting spurious exclamation points (!) where line lengths are
too long. Manually inserting line breaks (which do not render in HTML) seems
to solve the problem. Can someone tell me how to do this?
Put another way, I need to flesh out the following pseudocode:
Dim myString, myCursorPosition, myIncrement
myString ="The quick brown fox jumped over the lazy dog."
myCurrentCursorPosition=0
myIncrement=5 ' I want a line break for every myIncrement
While [there are still remaining characters to walk through in the string
' navigate cursor by myIncrement through myString
...
' insert a VbLf at myCurrentCursorPosition
...
myCurrentCursorPosition = myCurrentCursorPosition + myIncrement
[loop]
Thanks for any help on the syntax here.
-KF
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/asp-vbscript-for-a-declared-string-inserting-a-line-break-every-n-characters/m-p/844676#M188660
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
Try something like
for i=0 to len(mySt) step 5
mySt=left(mySt,i) & vbcrlf & right(mySt,len(mySt)-i)
next
--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004
for i=0 to len(mySt) step 5
mySt=left(mySt,i) & vbcrlf & right(mySt,len(mySt)-i)
next
--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/asp-vbscript-for-a-declared-string-inserting-a-line-break-every-n-characters/m-p/844677#M188661
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
Thanks, this code works just fine. However, I'm realizing
that my logic is
going to need to be a little more sophisticated. The string that I am
breaking includes HTML code. Inserting a VbCr can mess up the code.
I need a way so that the breaks won't break code. Any ideas? If I could
identify a char that only appeared in written text, that's one hacky
solution.
Thanks again,
-KF
"Julian Roberts" <nospam@charon.co.uk> wrote in message
news:e52kjj$shd$1@forums.macromedia.com...
> Try something like
>
> for i=0 to len(mySt) step 5
> mySt=left(mySt,i) & vbcrlf & right(mySt,len(mySt)-i)
> next
>
> --
> Jules
> http://www.charon.co.uk/charoncart
> Charon Cart 3
> Shopping Cart Extension for Dreamweaver MX/MX 2004
>
>
>
>
going to need to be a little more sophisticated. The string that I am
breaking includes HTML code. Inserting a VbCr can mess up the code.
I need a way so that the breaks won't break code. Any ideas? If I could
identify a char that only appeared in written text, that's one hacky
solution.
Thanks again,
-KF
"Julian Roberts" <nospam@charon.co.uk> wrote in message
news:e52kjj$shd$1@forums.macromedia.com...
> Try something like
>
> for i=0 to len(mySt) step 5
> mySt=left(mySt,i) & vbcrlf & right(mySt,len(mySt)-i)
> next
>
> --
> Jules
> http://www.charon.co.uk/charoncart
> Charon Cart 3
> Shopping Cart Extension for Dreamweaver MX/MX 2004
>
>
>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/asp-vbscript-for-a-declared-string-inserting-a-line-break-every-n-characters/m-p/844678#M188662
May 24, 2006
May 24, 2006
Copy link to clipboard
Copied
This is one possible solution specific to the problem I'm
having with MSXML.
Code is inefficient for explanatory clarity.
BodyAsHtmlString = replace(BodyAsHtmlString, "</a>", ("</a>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</td>", ("</td>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</table>",
("</table>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</tr>", ("</tr>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</br>", ("</br>"&vbcrlf))
-KF
"Ken Fine" <kenfine@u.washington.edu> wrote in message
news:e52ln5$i7$1@forums.macromedia.com...
> Thanks, this code works just fine. However, I'm realizing that my logic is
> going to need to be a little more sophisticated. The string that I am
> breaking includes HTML code. Inserting a VbCr can mess up the code.
>
> I need a way so that the breaks won't break code. Any ideas? If I could
> identify a char that only appeared in written text, that's one hacky
> solution.
>
> Thanks again,
> -KF
>
> "Julian Roberts" <nospam@charon.co.uk> wrote in message
> news:e52kjj$shd$1@forums.macromedia.com...
>> Try something like
>>
>> for i=0 to len(mySt) step 5
>> mySt=left(mySt,i) & vbcrlf & right(mySt,len(mySt)-i)
>> next
>>
>> --
>> Jules
>> http://www.charon.co.uk/charoncart
>> Charon Cart 3
>> Shopping Cart Extension for Dreamweaver MX/MX 2004
>>
>>
>>
>>
>
>
Code is inefficient for explanatory clarity.
BodyAsHtmlString = replace(BodyAsHtmlString, "</a>", ("</a>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</td>", ("</td>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</table>",
("</table>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</tr>", ("</tr>"&vbcrlf))
BodyAsHtmlString = replace(BodyAsHtmlString, "</br>", ("</br>"&vbcrlf))
-KF
"Ken Fine" <kenfine@u.washington.edu> wrote in message
news:e52ln5$i7$1@forums.macromedia.com...
> Thanks, this code works just fine. However, I'm realizing that my logic is
> going to need to be a little more sophisticated. The string that I am
> breaking includes HTML code. Inserting a VbCr can mess up the code.
>
> I need a way so that the breaks won't break code. Any ideas? If I could
> identify a char that only appeared in written text, that's one hacky
> solution.
>
> Thanks again,
> -KF
>
> "Julian Roberts" <nospam@charon.co.uk> wrote in message
> news:e52kjj$shd$1@forums.macromedia.com...
>> Try something like
>>
>> for i=0 to len(mySt) step 5
>> mySt=left(mySt,i) & vbcrlf & right(mySt,len(mySt)-i)
>> next
>>
>> --
>> Jules
>> http://www.charon.co.uk/charoncart
>> Charon Cart 3
>> Shopping Cart Extension for Dreamweaver MX/MX 2004
>>
>>
>>
>>
>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/dreamweaver-discussions/asp-vbscript-for-a-declared-string-inserting-a-line-break-every-n-characters/m-p/844679#M188663
May 25, 2006
May 25, 2006
Copy link to clipboard
Copied
Can you do a find and replace on the exclamation points?
myString = Replace(myString,"!",vbCrLf)
"Ken Fine" <kenfine@u.washington.edu> wrote in message
news:e52jtc$rnn$1@forums.macromedia.com...
> I'm using ASP VB. I want to insert a VbCr or a VbLf into a declared string
> every N characters. FWIW, I want to do this because of an apparent
> limitation in MSXML2, which I am using to "scrape" data from webpages that
> I control: I'm getting spurious exclamation points (!) where line lengths
> are too long. Manually inserting line breaks (which do not render in HTML)
> seems to solve the problem. Can someone tell me how to do this?
myString = Replace(myString,"!",vbCrLf)
"Ken Fine" <kenfine@u.washington.edu> wrote in message
news:e52jtc$rnn$1@forums.macromedia.com...
> I'm using ASP VB. I want to insert a VbCr or a VbLf into a declared string
> every N characters. FWIW, I want to do this because of an apparent
> limitation in MSXML2, which I am using to "scrape" data from webpages that
> I control: I'm getting spurious exclamation points (!) where line lengths
> are too long. Manually inserting line breaks (which do not render in HTML)
> seems to solve the problem. Can someone tell me how to do this?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

