Recently, I often see someone ask long English does not automatically change lines of the problem, which I wrote a function for everyone to reference

Source: Internet
Author: User
Reference | function | A long English with no spaces in it, the system thinks it is a word and does not automatically wrap to keep the word intact. In fact, this situation can not be dealt with, because in the actual application in addition to testing or some trouble will not occur, but in order to just in case, I wrote the following function a few months ago, is only a stopgap, in order to deal with the malicious spoilers.
'-------------------------------------------------
'
' Function name:autowrap
'
'
' Description: Solve the problem of not automatically wrapping in long English
'
' Parameters:a_strsourcestring: The source string to convert
'
' A_intsize, Width per line
'
' Author:bigeagle
'
' Date:2000/4/17
'
' History:2000/4/17:version 1.0
'
'-------------------------------------------------------
function AutoWrap (a_strsourcestring, A_intsize)

Dim l_strdeststring

' Exit if there is a carriage return in the content
' If InStr (A_strsourcestring, Chr () + CHR ()) <> 0 Then
' AutoWrap = replace (a_strsourcestring, Chr () + CHR (), <br>)
' Exit function
' End If

' Check if valid parameters
Call Assert (VarType (a_strsourcestring) = 8, "AutoWrap", "a_strsourcestring must to be a string")
Call Assert (VarType (a_intsize) = 2, "AutoWrap", "a_intsize must to be an integer")


Dim i
If A_intsize >= len (a_strsourcestring) Then
l_strdeststring = a_strsourcestring
Else
' l_strdeststring = Left (a_strsourcestring, a_intsize)
For i = 1 to len (a_strsourcestring) Step a_intsize
If InStr (I, Mid (a_strsourcestring, I, a_intsize), Chr (32)) = 0 _
or InStr (I, Mid (a_strsourcestring, I, a_intsize), Chr (a) +CHR) then
l_strdeststring = l_strdeststring + "" + Mid (a_strsourcestring, i + 1, a_intsize)
Else
l_strdeststring = l_strdeststring + mid (a_strsourcestring, i + 1, a_intsize)
End If
Next
End If

Call Print ("[Autowrap:]return value is: '" + l_strdeststring + "")
l_strdeststring = replace (l_strdeststring, Chr () + CHR (), <br>)
AutoWrap = l_strdeststring
End Function



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.