Skip to main content
Inspiring
January 30, 2018
Question

Dynamically referencing an array

  • January 30, 2018
  • 0 replies
  • 217 views

I'm working with some hierarchical data and I've ran into a bit of a problem. 

It's easiest to think about this problem if you can envision what a directory structure would look like in a multi-dimensional array. What I do is run a query and take the results and popultate an array with them.

Sometimes I can reference the Array by using this notation:   RootArray[1][4][1][1]   Basically the first record in the array has a multi dimensional array in the 4th cell.  

It's totally possible that the next record will be referenced like this:  RootArray[1][4][1][4][1][1].   In this case the first record in the array has a multi dimensional array in the 4th cell.  The 4th cell also contains a multi-dimensional array.    Reading the data out of the array is no big deal... writing the data on the other hand...  😠

Anyway...   I can dynamically build the string without any problem.   Thing is after I run this command:  <CFSET MyDir = 'RootArray[1][4][1][4][1][1]'> 

How do I use my newly created string to add data to the appropriate cell?  I can't use <CFSET MyDir = NewValue> because that just overwrites the string in the MyDir variable. 

So how do I use a dynamically built string to access a multi-dimensional array? 

Thanks in advance for the help!!!

Have an Ordinary Day....

Kurtis   ~|:-)

    This topic has been closed for replies.