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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFLOOP

Status
Not open for further replies.

stroll

Programmer
Sep 15, 2000
20
CA
Hi,

I am trying to use cfloop to iterate through the characters of a string one at a time. I would like to start at the first character and go to the last character in the string.

I used "Len(string)" to get the length of the string, and placed that expression after TO =. When I run it, it states that it cannot convert Len("string") to a number.
Doesn't Len return a number?

Thanks
Ryan [sig][/sig]
 
Len does return a number... you may want to check your use of (",') or maybe the "string" wasn't set yet?

using a combination of len() and mid() you could loop through a string of charachters. I am guessing that the task you are performing may be better suited to use of "regular expressions" but... here is a "string" loop.


<cfset String = 'A simple string value!'>

<cfloop from=&quot;1&quot; to=&quot;#len(string)#&quot; index=&quot;ThisChar&quot;>
<cfoutput>#Mid(string,ThisChar,1)#</cfoutput><br>
</cfloop>

If you ever have any questions, I am a full time Cold Fusion &quot;helper&quot;, working for cfhub.com.

email:feedback@cfhub.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top