Big Text and Word Wrapping

Results 1 to 3 of 3

Thread: Big Text and Word Wrapping

  1. #1
    Norman King Guest

    Default Big Text and Word Wrapping

    I have an ASP VBScript Function named BigText, it handles Big Text and chunks it out in X Sized Chunks. Problem is that it also splits words. Anyone have any way to check to see if a word is being cut into and adjust my function to handle word wrapping? Thanks!<BR><BR>Function BigText(s_Text, i_Len)<BR>&#039 Prints out Big Text in small chunks<BR>Dim i_pos &#039 position in string<BR>Dim s_Temp<BR> <BR> If Trim("" & s_Text) &#060;&#062; "" Then<BR> s_Temp = ""<BR> i_pos = 1<BR> &#039 Loop through and print out all of the text in case it is too long.<BR> Do While i_pos &#060; Len(s_Text)<BR> s_Temp = s_Temp & Mid(s_Text,i_pos,i_Len) & "<BR>"<BR> i_pos = i_pos + i_Len &#039Advance to the next i_Len characters<BR> Loop<BR> BigText = s_Temp<BR> Else<BR> BigText = "&nbsp;" &#039Must be blank or Null, set to a non-breaking space<BR> End If<BR>End Function

  2. #2
    Norman King Guest

    Default RE: Big Text and Word Wrapping

    On the s_temp assignment it took out the BR tag, which would have put a carriage return between the chunks. Thanks ASP Forum Message Board for filtering out HTML Tags! :(

  3. #3
    Norman King Guest

    Default RE: Big Text and Word Wrapping

    Ok I think I figured it out. Forgive me if the forum reformats the text. Change the "[br]" into the one with the greater than and less than for the HTML tag. <BR><BR><BR>Function BigText(s_Text, i_Len)<BR>&#039 Prints out Big Text in small chunks<BR>Dim i_pos &#039 position in string<BR>Dim s_Temp<BR>Dim s_Line<BR>Dim i_space &#039Location of Space<BR> <BR> If Trim("" & s_Text) &#060;&#062; "" Then &#039Not Blank or Null<BR> s_Temp = ""<BR> i_pos = 1<BR> &#039 Loop through and print out all of the text in case it is too long.<BR> Do While i_pos &#060; Len(s_Text) &#039While part we are looking at is less than the whole thing<BR> s_Line = Mid(s_Text,i_pos,i_Len) &#039Get a line i_Len long<BR> i_space = i_Len &#039Set i_space to i_Len<BR> If Len(s_Line) = i_Len Then &#039If i_Len characters, scan for a space<BR> If Right(s_Line,1) &#060;&#062; " " Then <BR> &#039If last character is not a space, backup and find a non-space to wrap the word<BR> <BR> Do While Right(s_Line,1) &#060;&#062; " " AND i_space &#062; i_pos <BR> &#039 If not space, back up until we hit the old position or a non-space<BR> i_space = i_space - 1 &#039Go back one character<BR> s_Line = Mid(s_Text,i_pos,i_space) &#039Refresh the line<BR> Loop<BR> If i_space = i_pos Then<BR> &#039 If we hit the last position, use the whole line<BR> s_Line = Mid(s_Text,i_pos,i_Len)<BR> i_space = i_Len<BR> End If<BR> End If<BR> End If<BR> s_Line = Mid(s_Text,i_pos,i_space) &#039Refresh the line<BR> s_Temp = s_Temp & s_Line & "[br]" &#039Add a CR/LF aka BR tag after the line<BR> <BR> i_pos = i_pos + i_space &#039Advance to the next i_space characters<BR> Loop<BR> BigText = s_Temp &#039Set the function to the parsed out, word wrapped, line<BR> Else<BR> BigText = "&nbsp;" &#039Must be blank or Null, make it a non-breaking space<BR> End If<BR>End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •