nested structure question....

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

  1. #1

    Default nested structure question....

    Hi,

    I posted a previous question somewhat similar to the one below, however, I am
    trying to determine if I can even use structures in this manner..

    I am getting erorrs like trying to dereference scalar values of type
    java.string, etc. I also get some other error around my <cfset> tags because
    of the period. I am using dot notation and it throws a basic error message as
    well.

    I am trying to create a nested structure, but have the name of the nested
    structure be dynamic. So for every state in my loop, a new structure gets
    created and its given a dynamic name. To further see what I am trying to do,
    look at the StructInsert() that was used further down in the code...

    Hope this makes sense.. There must be a solution to this. I am open to
    another way as well...

    <cfquery name="qryStates" datasource="#request.dsn#">
    SELECT StateID, StateName
    FROM States
    </cfquery>

    <cfquery name="qryNewCars" dbtype="query">
    SELECT theCount
    FROM TableName
    WHERE theCar = 'N'
    </cfquery>

    I have 2-3 more of these queries similar to the one immediately above. They
    just filter on if the car is new, old or used.

    <cfset theStruct = structNew()>

    <cfloop query="qryStates">

    <cfset "#stateID#" = StructNew()>

    <cfloop query="qryNewCars">
    <cfset #stateID#.new = theCount>
    </cfloop>

    <cfloop query="qryUsedCars">
    <cfset #stateID#.used = theCount>
    </cfloop>

    <cfloop query="qryOldCars">
    <cfset #stateID#.old = theCount>
    </cfloop>

    <cfset StructInsert(theStruct, "#stateName#", #stateID#)>

    </cfloop>

    <cfdump var="#theStruct#">
    <cfabort>

    Any help appreciated..

    thx

    WestSide Guest

  2. Similar Questions and Discussions

    1. FMS app structure question
      Hi I'm still feeling my way with media server and need a little help. I'm making a chat app with multiple rooms. I need to have a directory...
    2. Site Structure Question
      I'm in the process of implemeting Contribute 3.1/CPS 1.1 under IIS6. Our organizational structure requires that user wear many hats, so in the site...
    3. Dynamic Structure Question?
      Hi, I wanted to know if possible. Can I have a dynamic structure name? some generic query <cfquery name="qryTest"...
    4. Using CGI to return directory structure question
      Is it possible to have a cgi hit the root directory and send the results to a table? I've seen where it can be done on the current directory, but...
    5. DB structure question
      Access 2000. I'm trying to create a DB that stores records of books, but my understanding of DBases is very simple at best so, I have a table...
  3. #2

    Default Re: nested structure question....

    > <cfset #stateID#.new = theCount>

    That's a syntax error.

    Try
    <cfset "#stateID#.new" = theCount>

    Or better:
    <cfset variables["#stateID#.new"] = theCount>

    Same problem in a couple of other places, too.

    --

    Adam
    Adam Cameron 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