ColdFusion Structure

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

  1. #1

    Default ColdFusion Structure

    How to search the following structure of arrays for a user-provided string and
    return the key and array position of the match, if any.



    <cfscript>

    teams = StructNew();

    teams.basketball =
    ListToArray("Heat,Jazz,Lakers,Celtics,Spurs,Piston s,Pacers,Bulls,Nets,Knicks",
    ",") teams.football =
    ListToArray("Giants,Colts,Bengals,Bears,Dolphins,F alcons,Buccaneers,49ers,Bronco
    s,Rams", ","); teams.baseball = ListToArray("Reds,Braves,Cardinals,Cubs,White
    Sox,Red Sox,Yankees,Mets,Mariners,Diamondbacks", ","); teams.hockey =
    ListToArray("Red Wings,Blackhawks,Avalanche,Blues,Thrashers,Lightni ng,Maple
    Leafs", ","); </cfscript>

    Please help me in this regard

    Thanks
    Amy

    BenAmy Guest

  2. Similar Questions and Discussions

    1. Class::Struct - want to access structure within structure
      I want to access a structure within a structure. Below is what I had in mind. Please help. #!/perl/bin/perl use Class::Struct; struct Step...
    2. Add to Structure
      I'm a structures newbie. I need to know how to 1) Determine if a structure already exists 2) If not, create it. If yes, add to it. I've got...
    3. Class v. Structure
      Is there any performance considerations for a web service returning a structure versus an instance of a class?
    4. W3D structure...
      Hi My big problem is that I have some deformations that are already defined by vertices index, and their moves... But these deformations are...
    5. what is this data structure?
      Hi, I don't know how to work with this data structure: my @array = ((a => 'appple'), (b => 'tree'), (c => 'chair')); when I do:
  3. #2

    Default Re: ColdFusion Structure

    <cfset sought="Celtics">
    <cfloop collection="#teams#" item="itm">
    <cfloop from="1" to="#arrayLen(teams[itm])#" index="idx">
    <cfif sought eq #teams[itm][idx]#>
    <cfset myIndex = idx>
    <cfset myStrVal = itm>
    </cfif>
    </cfloop>
    </cfloop>

    <cfdump var="#variables#">

    i tired to post this a second ago. hmm. anyway, should help. another thought
    is to stick with an embedded structure and use the StructFind() function for
    the whole thing. (but watch for dupes with this method)

    ps: you're missing a ; in your script

    JJBBDD 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