loop through a string

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default loop through a string

    hello
    i wonder if its possible to loop through a string. i need to do it because i
    have to convert every single character so unicode after submiting the form.
    or do i need to create a list?

    thanks
    k

    Kiriran Guest

  2. Similar Questions and Discussions

    1. Loop option set, but flash doesn't loop
      I'm loading some swf files on my website and they all use the same code. They include the loop=true command but some loop and some don't. Does...
    2. Can a film loop play once, then loop on the last frame(s)?
      I need a film loop to play once, then loop playback on the last frame so I can keep the LOOP of the film loop set. This will allow the tell commands...
    3. Film loop rollovers working with tell sprite, but only if Loop is checked
      on mouseWithin me cursor 280 tell sprite 40 --the sprite containing the film loop sprite(60).member = member("networkmapsbuttonroll") --swapping...
    4. Urgent: Repeat loop and Film loop clash!
      Hi All, Scenario I have a script running in which the spelling which was typed in by the student is corrected. The alphabets are moved to...
    5. Help with loop inside loop and mysql queries
      Hi List. I cannot see my error: I have relation tables setup. main id entity_name main_type etc etc date_in 1 test type1 x y 2003-06-02...
  3. #2

    Default Re: loop through a string

    Sure.

    Loop on the length of the string. Use Mid(string, start, count) to get your character. Update start. Use count = 1.

    I think that oughta do it.

    -Shawn
    shawnwindler Guest

  4. #3

    Default Re: loop through a string

    To expand on what shawn said:

    <cfset myString = "Hello World!">
    <cfloop index="idx" from="1" to="#len(myString)#">
    <cfset character = mid(myString,idx,1)>
    <cfoutput>#character#</cfoutput>
    </cfloop>

    Kronin555 Guest

  5. #4

    Default Re: loop through a string

    This should also work...

    <CFSCRIPT>
    myString = "Hello World!,foo,bar,MEOW";
    FOR (i=1; i LTE ListLen(myString, ","); i=i+1) {
    writeOutput(ListGetAt(myString,i,",") & "<BR>");
    }
    </CFSCRIPT>
    DaveF67 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139