I am trying to load an array with wrapped lines from the text field. We are
feeding this into a function that takes the text and dynamically puts this in a
graphic via java.
Each element in the array will contain a line that is either wrapped or ended
by a cr/lf when the user hits enter at the end of the line
I populate a temp var with the 1st 34 characters of string. I look to see if
there are any of the above chr values...if not, then I back up until i find a
space and use that value as the EOL. Next line start at EOL +1 and I repeat
until I am out of string.
here's the string (and how it should be formatted):
Life is but a stopping place,
A pause in what's to be.
A resting place along the road,
To sweet eternity.
string temp for the first run:
Life is but a stopping place,A p
the return after all the processing is:
Life is but a stopping place,A
Here's the code...
<cfset txtLen=len(variables.text.string)>
<cfset arraylimit=0>
<cfset linelen=#arguments.char_count#>
<cfset startelem=1>
<cfset arrayelem=1>
<cfset lb = chr(13) & chr(10)>
<cfdump var="start loop"><br>
<cfdump var="#variables.text.string#"><br>
<cfset variables.text.txtLines=arrayNew(1)>
<cfset tempvar=linelen+arguments.char_count>
<cfdump var="#txtlen#/#tempvar#"><br>
<!--- <cfloop condition="txtlen LESS THAN
(linelen+arguments.char_count)"> --->
<cfdump var="#arraylimit#"><br>
<cfset
stringtemp=mid(variables.text.string,startelem,arguments.char_count)>
<cfdump var="#stringtemp#"><br>
<cfset
linebreak=findnocase(stringtemp,"#chr(10)##chr(13)#","#startelem#")>
<cfif linebreak is 0>
<cfset
linebreak=findnocase(stringtemp,"#chr(10)#","#startelem#")>
</cfif>
<cfif linebreak is 0>
<cfset
linebreak=findnocase(stringtemp,"#chr(13)#","#startelem#")>
</cfif>
<cfdump var="lb=#linebreak#"><br>
<cfif linebreak neq 0>
<cfset linelen=linebreak>
</cfif>
<cfloop from="#linelen#" to="#startelem#"
index="charval" step=-1>
<cfdump var="#startelem# to #linelen#"><br>
<cfif mid(variables.text.string,charval,1) neq
"#chr(32)#">
<cfdump
var="#charval#(#gettoken(variables.text.string,charval)#)"><br>
<cfset linelen=linelen-1>
<cfdump var="char is not a
space"><br>
<cfelse>
<cfset elemdiff=0>
<cfdump var="eol"><br>
<cfbreak>
</cfif>
</cfloop>
<cfset variables.text.txtLines[arrayelem]="
"&mid(variables.text.string,startelem,linelen)>
<cfdump var="array element #arrayelem# =
#variables.text.txtLines[arrayelem]#"><br>
<cfset startelem=linelen+elemdiff+1>
<cfset linelen=linelen+arguments.char_count+1>
<cfset arrayelem=arrayelem+1>
>What do you want to do. Are you looking to replace with <br>?
>
>
>Robert B. Harrison
>Director of Interactive Services
>Austin & Williams
>125 Kennedy Drive, Suite 100
>Hauppauge NY 11788
>P : 631.231.6600 Ext. 119
>F : 631.434.7022
>http://www.austin-williams.com
>
>Great advertising can't be either/or. It must be &.
>
>Plug in to our blog: A&W Unplugged
>http://www.austin-williams.com/unplugged
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339049
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm