This is my final function and I did end up using split. Basically I
didn't know what I wanted until I started playing around at first
attempt I thought just break the str up every 40 chars well that
obviously would chop up words. My needs were simple I had to insert a
<br> every so many characters (width variable). It may not be elegant
but it works. I have taken heat for posting to begin with but if anyone
has any comments on how to clean it up or if I didn't follow proper
syntax let me know.
Here is what I finally came up with:
Function InsertBreakatFullWords(str,width)
myarray = split(str)
for j = 0 to ubound(myarray)
if (len(mystring) - lastlength) > width then
mystring = mystring & myarray(j) & " " & "<br>"
lastlength = len(mystring)
else
mystring = mystring & myarray(j) & " "
End if
next
InsertBreakatFullWords = mystring
End Function
Pete Lundrigan
Media Resources Center
Academic Web Support
316.978.7759
http://www.mrc.twsu.edu/
[EMAIL PROTECTED]
-----Original Message-----
From: Bostrup, Tore [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 07, 2002 7:31 AM
To: ActiveServerPages
Subject: RE: Split a String at a Specific Length
Why do a character at a time?
sWithBreak = ""
sSep = ""
lUpper = Int(Len(sText) / iWidth)
For i = 0 to lUpper
sWithBreak = sWithBreak & sSep & Mid(sText, i * iWidth + 1,
iWidth)
sSep = "<br>"
Next
Regards,
Tore.
-----Original Message-----
From: Pete Lundrigan [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 07, 2002 1:26 AM
To: ActiveServerPages
Subject: RE: Split a String at a Specific Length
I will take my lumps and go to sleep knowing that I should have never
posted to the list. I apologize for the inconvenience. You were
correct is was only a couple of lines. I was just having a mental block
or something.
Function InsertBreakatSpecificLength(str,width)
for i = 1 to len(str)
if i mod width = 0 then
mystring = mystring & mid(str,i,1) & "<br>"
else
mystring = mystring & mid(str,i,1)
End if
next
InsertBreakatSpecificLength = mystring
End Function
Pete Lundrigan
Media Resources Center
Academic Web Support
316.978.3575 http://www.mrc.twsu.edu/
mailto:[EMAIL PROTECTED]
-----Original Message-----
From: Roji Thomas [mailto:[EMAIL PROTECTED]]
Sent: Sunday, October 06, 2002 11:55 PM
To: ActiveServerPages
Subject: Re: Split a String at a Specific Length
No I guess.
But y not write it?
Afterall its a matter of a few lines
And u can have that "geek smile"
at the end of the day.
----- Original Message -----
From: "Pete Lundrigan" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Monday, October 07, 2002 9:52 AM
Subject: Split a String at a Specific Length
Is there a function similar to Split to Split a string every 40
characters instead of Splitting at a specific character?
---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]