ASP Code
  Home arrow ASP Code arrow Parse Text without splitting words by Luke...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

Parse Text without splitting words by Luke Latimer
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2000-10-08

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    ******************************
    '**************************************************
    '*     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

     

    IBM® developerWorks developerWorks - FREE Tools!


    Build Forge Express demo: Enabling software delivery excellence for small and midsized businesses

    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!


    NEW! Application Development Tools for the Mainframe Developer

    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!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    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!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    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!


    NEW! IBM Enterprise Modernization Sandbox for System z: Architecture

    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!


    NEW! Rational 'Talks to You' Teleconference Series

    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!


    NEW! Rational Talks to You:Per Kroll on Rational Method Composer Plug-in customization

    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!


    NEW! Rational Talks to You: Scott Ambler on being agile in a global development environment

    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!


    NEW! Rational Testing eKits

    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!


    NEW! Webcast: WebSphere Process Server

    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!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway