House of Fusion
Home of the ColdFusion Community

Search cf-talk

October 08, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Simple List Question

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Che Vilnonis
05/15/2008 04:04 PM

Probably been covered before... How do I take a word like, "apple" and loop through each letter? I'd like to end up with "a.p.p.l.e". Thanks, Che

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
05/15/2008 04:12 PM

>Probably been covered before... >How do I take a word like, "apple" and loop through each letter? I'd like to >end up with "a.p.p.l.e". > >Thanks, Che loop through the length of the string using len(currentString) then use the mid function to get each character: mid(currentString,loopCounter,1)

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Che Vilnonis
05/15/2008 04:23 PM

Thanks Richard... It was the len(string) statement that I was forgetting. >Probably been covered before... >How do I take a word like, "apple" and loop through each letter? I'd >like to end up with "a.p.p.l.e". > >Thanks, Che loop through the length of the string using len(currentString) then use the mid function to get each character: mid(currentString,loopCounter,1)

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude Schneegans
05/15/2008 04:22 PM

>>How do I take a word like, "apple" and loop through each letter? Try this: <CFSET word = "apple"> <CFLOOP INDEX="c" FROM="1" TO="#len(word)#">   <CFSET currentChar = mid(word,c,1)>   <CFOUTPUT>currentChar = #currentChar#<BR></CFOUTPUT> </CFLOOP> -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jim McAtee
05/15/2008 04:22 PM

You can't treat a word as a list of letters, because there's no delimiter. Use something like: <cfset s = "apple"> <cfset t = ""> <cfloop index="i" from="1" to="#len(s)#"> <cfset t &= mid(s, i, 1) & "."> </cfloop> <cfoutput>#t#</cfoutput> > Probably been covered before... > How do I take a word like, "apple" and loop through each letter? I'd > like to > end up with "a.p.p.l.e".


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists