Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Spaces in strings

Status
Not open for further replies.

tempoman

Programmer
May 9, 2000
41
0
0
AU
Could someone help me, I am outputting some data into different table cells, however some of the data are quite long and cannot fit onto the printed copy. I have tried to resize the width of each cell so that it fits the page, however some on text does not contain any spaces and therefore does not word wrap.

Some of examples of my data are:
rsdeltagammaalpha
rs deltamimes dsd

etc.

String "rs deltamime dsf" fits into three lines with a smaller cell width, however "rsdeltagammaalpha" cell width is the same as the length of the string.

Is there a way I can insert a space after a certain amount of characters have been displayed and thus cutting the string "rsdeltagammaalpha" into 3 sections.

Thanks heaps

Richard
 
Try this code, havent tested it out though. alter myInterval as needed. Hope this helps :)

<CFSET myString = &quot;rsdeltagammaalpha&quot;>

<CFSET mySpace = &quot; &quot;>
<CFSET myInterval = 5>
<CFSET myNum = Len(myString) MOD myInterval>
<CFLOOP INDEX=&quot;i&quot; FROM=&quot;1&quot; TO=&quot;myNum&quot;>
<CFSET pos = i*myInterval>
<CFIF pos LT Len(myString)>
<CFSET myString = Insert(mySpace, myString, pos)>
</CFIF>
</CFLOOP>

Gana
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top