****************************** '************************************************** '* Script written by: Luke Latimer '* on: 18/09/2000 '* '* Name: ParseText.vbs '* Description: '* This script consists of a function (ParseText) that '* takes as parameters a string, and a number, and a '* Line Break delimiter (can be VbCrlf). '* The output is the text containing the delimiter according to the '* value passed. If there are spaces present in the text '* The function will attempt to avoid splitting words. '* Use arr=Split(ParsedText,Delimiter) to extract the lines from the output. '* '****************************************************
Dim Text, WrapAt, Delimiter WrapAt=80 Delimiter="#Delimiter#"
'For use when testing with WSH 'text=inputbox("Enter some text, if it's bigger than " & WrapAt & " chars then it will be wrapped onto the next line")
myText=Request.Form("TheTextBox_or_Area") 'Or load from DB
myTextArr=Split(ParseText(myText, WrapAt, Delimiter), Delimiter)
For i=0 to UBound(myTextArr) Response.Write myTextArr(i) & "<BR>" Next
FUNCTION ParseText(Text,WrapAt,Delimiter)
If len(text)>WrapAt then 'start wrapping it
Dim index index=0
Do While Len(Text)>WrapAt 'don't wrap the text halfway through a word if it can be helped
If Instr(Left(Text,WrapAt)," ")=0 Then 'No spaces, split words?
If ParseText="" Then ParseText= Left(Text,WrapAt) Else ParseText=ParseText & Delimiter & Left(Text,WrapAt) End if
If Len(Text)> WrapAt Then Text=Right(Text,Len(Text)-WrapAt) If Len(Text)<=WrapAt Then If ParseText="" Then ParseText= Text Else ParseText=ParseText & Delimiter & Text End if End if End if
Else
tempText=Left(Text,WrapAt) SplitAt=Instr(strReverse(tempText)," ") If SplitAt>0 Then Buffer=1 If SplitAt=WrapAt Then If ParseText="" Then ParseText=TempText Else ParseText=ParseText & Delimiter & TempText End if Else If ParseText="" Then ParseText=Left(tempText,Len(tempText) -SplitAt+Buffer) Else ParseText=ParseText & Delimiter & Left(tempText,Len(tempText) -SplitAt+Buffer) End if End if
If Len(Text)>WrapAt Then If SplitAt=WrapAt Then Text=Right(Text,Len(Text)-WrapAt) Else Text=Right(Text,Len(Text)-(WrapAt-SplitAt+Buffer)) End if If Len(Text)<=WrapAt Then If ParseText="" Then ParseText=Text Else ParseText=ParseText & Delimiter & Text End if End if End if End if Index=Index+1 Loop Else
ParseText=Text
End if
End FUNCTION ****************************** |
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | This demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process. FREE! Go There Now!
| | | | You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months. FREE! Go There Now!
| | | | This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer. FREE! Go There Now!
| | | | This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
| | | | Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
| | | | This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today! FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on December 11 at 1:00 pm ET to get tips on building your own plugins with Rational Method Composer. Get your questions answered! FREE! Go There Now!
| | | | Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered! FREE! Go There Now!
| | | | Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing. FREE! Go There Now!
| | | | WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |