Word-wrap ASP Output on Long Strings with No Blanks

Word-wrap ASP Output on Long Strings with No Blanks

If you need to output to the screen or print a long text string that has no spaces, the text string will not wrap to the preset dimensions of a table or to the browser window frame.

This simple function will wrap the text string based on any setting you provide:

<%Function WordWrap(OrigString)StrLength = Len(OrigString)intPosition = 1StrWrapNumber = 80StrLoop = StrLength StrWrapNumberIf StrLoop > 0 thenFor LoopStep = 0 to StrLoop	WrapString = Mid(OrigString, intPosition, StrWrapNumber)	Response.Write WrapString	Response.Write "
" intPosition = intPosition + StrWrapNumberNextElse Response.Write OrigStringEnd ifEnd Function%>

You can change the length of the block in the line

StrWrapNumber = 80

You can use this function as an include page and call it like so:

<%dim f_ OverallGoalf_OverallGoal = Result1("OverallGoal")response.write WordWrap(f_OverallGoal)%>

Note: This example applies to re-displaying from a database query; forre-displaying a form before submittal just use Request.Form rather thanResult1, etc.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several