RE: Inserting rows into a 2d array
Well, my first suggestion is to combine at least the first two loops. You should be able to check for the breaks you want, while you are converting the query to the array, and insert the blank rows at that time. This way, you don't even need the ArrayInsertAt function. Something like this. That should cut the processing time by about 30% by eliminating one loop. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA -Original Message- From: DougF [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 18, 2003 10:58 AM To: CF-Talk Subject: Re: Inserting rows into a 2d array Thanks Ian, - Original Message - From: "Ian Skinner" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 11:06 PM Subject: Re: Inserting rows into a 2d array > What took me a little to get my head around, when I first learned Cold Fusion Arrays, is that, > when you have a two dimension Array, it does not have to be a grid or table. It is more proper > to visualize it as a one dimension array, that each element contains individual one dimension arrays. > Thus you can have different size arrays at each element. Yes, understanding that each element contains an individual one dimension array was the ah ha moment for me. Was looking for an example to get it through my thick head... > ...don't bother creating a blank placeholder array. Just put the ArrayNew(1) function as the third parameter > of the ArrayInsertAt function. This creates a blank new array at the new position. Then, if you later > decide you need to put data here, you can just use simple assignment. I need the three elements in the new array or logic that uses the new array will choke when it hits a non-existence element. At most there are any about 20 inserts on the largest record set processed so I don't it makes much difference to the speed. > ...just as a last thought. Your method requires the code to loop through all the data three times. Once > to transfer the data from the query to the array, once to process blank rows into the array, and a third time > to display it. I would be a bit leery for something like this on a high traffic page with a large data set. Efficiency is now the challenge. Was suspicious of this and testing confirmed that record sets of 100 or more were noticeably slower even on fast development server. Converting to a CFscript helped. Tickcount is still about 70 ms with record set of 500. Any suggestions to help speed it up? -- My2DArray = ArrayNew(2); row = 1; while (row LTE query.RecordCount) { My2DArray[row][1] = query.city_name[row]; My2DArray[row][2] = query.lcid[row]; My2DArray[row][3] = query.listingcount[row]; row = row + 1; } firstLetter = "A"; countVar = 1; // if (ArrayLen(My2DArray) GT 20) while (countVar LTE (ArrayLen(My2DArray))) if (Left(My2DArray[countVar][1],1) NEQ firstLetter) { firstLetter = left(My2DArray[countVar][1],1); NewElement = ArrayNew(1); NewElement[1] = ""; NewElement[2] = ""; NewElement[3] = ""; InsertSuccess = ArrayInsertAt(My2DArray, countVar, NewElement); countVar = countVar + 1; } else {countVar = countVar + 1;} _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
(sorry sent last message before it was finished) Thanks Ian, > What took me a little to get my head around, when I first learned Cold > Fusion Arrays, is that, when you have a two dimension Array, it does > not have to be a grid or table. It is more proper to visualize it as a one > dimension array, that each element contains individual one dimension > arrays. Thus you can have different size arrays at each element. Yes, understanding that each element contains an individual one dimension array was the ah ha moment for me. Was looking for an example to get it through my thick head... > ...don't bother creating a blank placeholder array. Just put the > ArrayNew(1) function as the third parameter of the ArrayInsertAt > function. This creates a blank new array at the new position. Then, > if you later decide you need to put data here, you can just use simple > assignment. I need the three elements in the new array or logic that uses the new array will choke when it hits a non-existence element. At most there are any about 20 inserts on the largest record set processed so I don't it makes much difference to the speed. > ...just as a last thought. Your method requires the code to loop through > all the data three times. Once to transfer the data from the query to the > array, once to process blank rows into the array, and a third time > to display it. I would be a bit leery for something like this on a high > traffic page with a large data set. Efficiency is now the challenge. Was suspicious of this and testing confirmed that record sets of 100 or more were noticeably slower even on fast development server. Converting to a CFscript helped. Tickcount is still about 70 ms with record set of 500. Any suggestions to help speed it up? -- My2DArray = ArrayNew(2); row = 1; while (row LTE query.RecordCount) { My2DArray[row][1] = query.city_name[row]; My2DArray[row][2] = query.lcid[row]; My2DArray[row][3] = query.listingcount[row]; row = row + 1; } firstLetter = "A"; countVar = 1; // if (ArrayLen(My2DArray) GT 20) while (countVar LTE (ArrayLen(My2DArray))) if (Left(My2DArray[countVar][1],1) NEQ firstLetter) { firstLetter = left(My2DArray[countVar][1],1); NewElement = ArrayNew(1); NewElement[1] = ""; NewElement[2] = ""; NewElement[3] = ""; InsertSuccess = ArrayInsertAt(My2DArray, countVar, NewElement); countVar = countVar + 1; } else {countVar = countVar + 1;} [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
Thanks Ian, - Original Message - From: "Ian Skinner" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 11:06 PM Subject: Re: Inserting rows into a 2d array > What took me a little to get my head around, when I first learned Cold Fusion Arrays, is that, > when you have a two dimension Array, it does not have to be a grid or table. It is more proper > to visualize it as a one dimension array, that each element contains individual one dimension arrays. > Thus you can have different size arrays at each element. Yes, understanding that each element contains an individual one dimension array was the ah ha moment for me. Was looking for an example to get it through my thick head... > ...don't bother creating a blank placeholder array. Just put the ArrayNew(1) function as the third parameter > of the ArrayInsertAt function. This creates a blank new array at the new position. Then, if you later > decide you need to put data here, you can just use simple assignment. I need the three elements in the new array or logic that uses the new array will choke when it hits a non-existence element. At most there are any about 20 inserts on the largest record set processed so I don't it makes much difference to the speed. > ...just as a last thought. Your method requires the code to loop through all the data three times. Once > to transfer the data from the query to the array, once to process blank rows into the array, and a third time > to display it. I would be a bit leery for something like this on a high traffic page with a large data set. Efficiency is now the challenge. Was suspicious of this and testing confirmed that record sets of 100 or more were noticeably slower even on fast development server. Converting to a CFscript helped. Tickcount is still about 70 ms with record set of 500. Any suggestions to help speed it up? -- My2DArray = ArrayNew(2); row = 1; while (row LTE query.RecordCount) { My2DArray[row][1] = query.city_name[row]; My2DArray[row][2] = query.lcid[row]; My2DArray[row][3] = query.listingcount[row]; row = row + 1; } firstLetter = "A"; countVar = 1; // if (ArrayLen(My2DArray) GT 20) while (countVar LTE (ArrayLen(My2DArray))) if (Left(My2DArray[countVar][1],1) NEQ firstLetter) { firstLetter = left(My2DArray[countVar][1],1); NewElement = ArrayNew(1); NewElement[1] = ""; NewElement[2] = ""; NewElement[3] = ""; InsertSuccess = ArrayInsertAt(My2DArray, countVar, NewElement); countVar = countVar + 1; } else {countVar = countVar + 1;} [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
Glad you got this to work for you, but just as a last thought. Your method requries the code to loop through all the data three times. Once to transfer the data from the query to the array, once to process blank rows into the array, and a third time to display it. I would be a bit leary for something like this on a high trafic page with a large data set. If neither of these apply to this application then you shouldn't have a problem. But it's a trade off to be aware of if used on such a page. ___ Ian Skinner Web Developer Sierra Outdoor Recreation (http://www.SierraOutdoorRecreation.com) - Original Message - From: DougF To: CF-Talk Sent: Monday, November 17, 2003 9:22 PM Subject: Re: Inserting rows into a 2d array Thanks Dave. Just what I was fishing for... As a visual learner I need an example to help understand the concept. Here is what I have come up with. Tested, works, and solved my problem. - -- - Original Message - From: "Dave Watts" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 4:46 PM Subject: RE: Inserting rows into a 2d array > Something like this might work: > > > > > > > > > > > > > > Note that I haven't tested this, exactly, but something close to this should > work. You could also create the element in place, then populate it, I > suspect. > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > voice: (202) 797-5496 > fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
Looks like this may already be answered, but I just got around to playing with this. My solution is very similar, but maybe a bit more streamlined, if you are still just trying to add blank rows for output purposes. Dump Test Array Output Row 4 #Test[4][1]# #Test[4][2]# Dump Test Array After new row added Output Row 4 #Test[4][1]# #Test[4][2]# The only real difference then the other example, is I don't bother creating a blank placeholder array. Just put the ArraNew(1) function as the third parameter of the ArrayInsertAt function. This creates a blank new array at the new position. Then, if you later decide you need to put data here, you can just use simple assignment. ect. What took me a little to get my head around, when I first learned Cold Fusion Arrays, is that, when you have a two dimension Array, it does not have to be a grid or table. It is more proper to visualize it as a one diminsion array, that each element contains individual one diminsion arrays. Thus you can have different size arrays at each element. Something like this. 1 : Apples Oranges Peaches 2 : Joe Sally Jim Paul Mary Ringo George 3 : 1 2 3 4 5 6 7 8 9 10 4 : Cool 5 : A B C D E F G H I J K L M N O P Q Thus you have a 3 element sub-array in position 1, a 7 element sub-array in position 2, a 10 element sub-array in position 3, a 1 element sub-array in position 4 and finally 17 element sub-array in position 5. This is powerfull stuff, because each sub-element can contain another level of array, thus you can create truely mind boggeling array demeinsions, only limited by memory, performance and sanity. If you wanted an 11 dimension array {StringTheoryArray[2][3][1][5][7][8][1][9][17][22][4]}, this is perfectly leagle and allowed. May not be advisable, but you can do it. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Inserting rows into a 2d array
Doug, I read through the emails but I am not quite understanding what you are trying to accomplish.. You have a data set like... locationID cityName 1 AAA 2 AA 3 BB You want to take the above and populate into an array and put some spaces between A and B sorted? You already have the data sorted from the database.. You can loop through the resultset alphabetically and create a 2D Array, where each position only contains the first Aphabet. my2DArray[1] = will contain all "A" Starting cityNames or whatever" my2DArray[2][1] = "SPACE" // IS THIS WHAT YOU WANT? my2DArray[3] = will contain all "B" Starting cityNames or whatever" You can simply create a list like myList = "A, ,B...; loop over the list and populate your 2 Array HTH Joe Eugene -Original Message- From: DougF [mailto:[EMAIL PROTECTED] Sent: Monday, November 17, 2003 7:29 PM To: CF-Talk Subject: Re: Inserting rows into a 2d array Thanks Dave. Not having much knowledge of CF arrays I'd be interested in examples of how to go about inserting two associated elements between two other associated elements arrays. Example: [first][1] + [first][2] [second][1] + [second][2] [first][1] + [first][2] [NewElement][1] + [NewElement][2] [second][1] + [second][2] -Doug - Original Message - From: "Dave Watts" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 3:36 PM Subject: RE: Inserting rows into a 2d array > > The Macromedia documentation skilfully avoids mentioning the > > manipulation of multi-dimensioned arrays. It seems that you > > can create multi-dimensional arrays but can not manipulate > > them (like you can with one dimension arrays). Going to take > > another look at manipulating with the display logic... sigh. > > Sure, you can manipulate multi-dimensional arrays. A multi-dimensional array > is simply an array that contains arrays in each position. > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > voice: (202) 797-5496 > fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
Thanks Dave. Just what I was fishing for... As a visual learner I need an example to help understand the concept. Here is what I have come up with. Tested, works, and solved my problem. - -- - Original Message - From: "Dave Watts" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 4:46 PM Subject: RE: Inserting rows into a 2d array > Something like this might work: > > > > > > > > > > > > > > Note that I haven't tested this, exactly, but something close to this should > work. You could also create the element in place, then populate it, I > suspect. > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > voice: (202) 797-5496 > fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Inserting rows into a 2d array
> Not having much knowledge of CF arrays I'd be interested in > examples of how to go about inserting two associated elements > between two other associated elements arrays. > > Example: > > [first][1] + [first][2] > [second][1] + [second][2] > > [first][1] + [first][2] > [NewElement][1] + [NewElement][2] > [second][1] + [second][2] Something like this might work: Note that I haven't tested this, exactly, but something close to this should work. You could also create the element in place, then populate it, I suspect. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
Thanks Dave. Not having much knowledge of CF arrays I'd be interested in examples of how to go about inserting two associated elements between two other associated elements arrays. Example: [first][1] + [first][2] [second][1] + [second][2] [first][1] + [first][2] [NewElement][1] + [NewElement][2] [second][1] + [second][2] -Doug - Original Message - From: "Dave Watts" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 3:36 PM Subject: RE: Inserting rows into a 2d array > > The Macromedia documentation skilfully avoids mentioning the > > manipulation of multi-dimensioned arrays. It seems that you > > can create multi-dimensional arrays but can not manipulate > > them (like you can with one dimension arrays). Going to take > > another look at manipulating with the display logic... sigh. > > Sure, you can manipulate multi-dimensional arrays. A multi-dimensional array > is simply an array that contains arrays in each position. > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > voice: (202) 797-5496 > fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Inserting rows into a 2d array
> The Macromedia documentation skilfully avoids mentioning the > manipulation of multi-dimensioned arrays. It seems that you > can create multi-dimensional arrays but can not manipulate > them (like you can with one dimension arrays). Going to take > another look at manipulating with the display logic... sigh. Sure, you can manipulate multi-dimensional arrays. A multi-dimensional array is simply an array that contains arrays in each position. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
A great CF Array learning experience... The Macromedia documentation skilfully avoids mentioning the manipulation of multi-dimensioned arrays. It seems that you can create multi-dimensional arrays but can not manipulate them (like you can with one dimension arrays). Going to take another look at manipulating with the display logic... sigh. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Inserting rows into a 2d array
When I have done displays like this, I put all the display logic in the code, leaving the data alone. Something along these lines (pseudo code); left(getdata.cityName,1)> #getdata.cityName# #getdata.LocationCode# secColumn> This will output pretty close to what you wanted in your example. It will display the first half of the query in one cell of a two cell row, and the second half in the other cell. Something like this. I hope the alignment comes through correctly in the email. xxx xxx y xxx xxx xxx xxx x If you want a display a little fancier, with the locations codes lined up in a column you will have to play with the table(s) a bit. Might be easiest to nest tables, but if you don't want to, it can be done with a bit more work. HTH -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA -Original Message- From: DougF [mailto:[EMAIL PROTECTED] Sent: Monday, November 17, 2003 11:08 AM To: CF-Talk Subject: Re: Inserting rows into a 2d array Thanks Dave, here is what I've discovered. Further ideas appreciated. Doug - Original Message - From: "Dave Watts" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 9:16 AM Subject: RE: Inserting rows into a 2d array > > Alternatively, why not just order the data the way you want it before > building the array? Or, perhaps more importantly, why does the ordering > matter at all? Ideally, in most (but not all) situations, it shouldn't. What I'm trying to do is take a query result with two associated elements named city_name and locationID. The two elements need to be displayed beside each other, ordered alphabetically on the city name, with a blank line between the end of one alpha group and the start of the next group (makes it much easier to visually scan through a long list). The results will be displayed in a four column, vertically ordered table. My idea is to insert blank spacers into the results before the table is dynamically constructed so that the table formatting is not messed up with the spacers running horizontally across all four columns of the table. AAA xxx CCC xxx AAA xxx DDD xxx BBB xxx BBB xxx EEE xxx CCC xxx FFF xxx > According to the documentation, existing elements should automatically be > shifted up one in position, so you shouldn't be having this problem. What > version of CF are you using? Using CF5. The way I understand the documentation is that the existing element is shifted one cell to the right, not up or down. In testing I found this to be true. The existing element is moved to the right and the new element is inserted as documentation states. This works whether the array is 1, 2 or 3 dimensional. Previously I thought the ArrayInsertAt was just overwriting the element but now know it was shifting the existing element to the right and not creating a new row as I was expecting. So the problem is that I want insert a new ROW into a 2 dimensional array not just add a new element (cell) to an existing row. This will create the spacer between existing elements. Ideas or alternatives appreciated. 'testArray1' has #ArrayLen(testArray1)# elements. #Num# #testArray1[Num]#, After insert 'testArray1' has #ArrayLen(testArray1)# elements. #Num1# #testArray1[Num1]#, 'testArray2' has #ArrayLen(testArray2)# elements. #Num2# #testArray2[Num2][1]#, #testArray2[Num2][2]#, After insert 'testArray2' has #ArrayLen(testArray2)# elements. #Num3# #testArray2[Num3][1]#, #testArray2[Num3][2]#, row 3 contents: #testArray2[3][1]#, #testArray2[3][2]#, #testArray2[3][3]# test results 'testArray1' has 3 elements. 1 Agness, 2 Albany, 3 Arlington, After insert 'testArray1' has 4 elements. 1 Agness, 2 Albany, 3 InsertAt3, 4 Arlington, 'testArray2' has 3 elements. 1 Agness, ID01, 2 Albany, ID02, 3 Arlington, ID03, After insert 'testArray2' has 3 elements. 1 Agness, ID01, 2 Albany, ID02, 3 InsertHere, Arlington, row 3 contents: InsertHere, Arlington, ID03 -- > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > voice: (202) 797-5496 > fax: (202) 797-5444 - Original Message - > > It was suggested (thanks Chris) that I could insert elements > > into an array by using the ArrayInsertAt() function: > > > > Example: > > For a 1d array
Re: Inserting rows into a 2d array
Thanks Dave, here is what I've discovered. Further ideas appreciated. Doug - Original Message - From: "Dave Watts" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Monday, November 17, 2003 9:16 AM Subject: RE: Inserting rows into a 2d array > > Alternatively, why not just order the data the way you want it before > building the array? Or, perhaps more importantly, why does the ordering > matter at all? Ideally, in most (but not all) situations, it shouldn't. What I'm trying to do is take a query result with two associated elements named city_name and locationID. The two elements need to be displayed beside each other, ordered alphabetically on the city name, with a blank line between the end of one alpha group and the start of the next group (makes it much easier to visually scan through a long list). The results will be displayed in a four column, vertically ordered table. My idea is to insert blank spacers into the results before the table is dynamically constructed so that the table formatting is not messed up with the spacers running horizontally across all four columns of the table. AAA xxx CCC xxx AAA xxx DDD xxx BBB xxx BBB xxx EEE xxx CCC xxx FFF xxx > According to the documentation, existing elements should automatically be > shifted up one in position, so you shouldn't be having this problem. What > version of CF are you using? Using CF5. The way I understand the documentation is that the existing element is shifted one cell to the right, not up or down. In testing I found this to be true. The existing element is moved to the right and the new element is inserted as documentation states. This works whether the array is 1, 2 or 3 dimensional. Previously I thought the ArrayInsertAt was just overwriting the element but now know it was shifting the existing element to the right and not creating a new row as I was expecting. So the problem is that I want insert a new ROW into a 2 dimensional array not just add a new element (cell) to an existing row. This will create the spacer between existing elements. Ideas or alternatives appreciated. 'testArray1' has #ArrayLen(testArray1)# elements. #Num# #testArray1[Num]#, After insert 'testArray1' has #ArrayLen(testArray1)# elements. #Num1# #testArray1[Num1]#, 'testArray2' has #ArrayLen(testArray2)# elements. #Num2# #testArray2[Num2][1]#, #testArray2[Num2][2]#, After insert 'testArray2' has #ArrayLen(testArray2)# elements. #Num3# #testArray2[Num3][1]#, #testArray2[Num3][2]#, row 3 contents: #testArray2[3][1]#, #testArray2[3][2]#, #testArray2[3][3]# test results 'testArray1' has 3 elements. 1 Agness, 2 Albany, 3 Arlington, After insert 'testArray1' has 4 elements. 1 Agness, 2 Albany, 3 InsertAt3, 4 Arlington, 'testArray2' has 3 elements. 1 Agness, ID01, 2 Albany, ID02, 3 Arlington, ID03, After insert 'testArray2' has 3 elements. 1 Agness, ID01, 2 Albany, ID02, 3 InsertHere, Arlington, row 3 contents: InsertHere, Arlington, ID03 -- > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > voice: (202) 797-5496 > fax: (202) 797-5444 - Original Message - > > It was suggested (thanks Chris) that I could insert elements > > into an array by using the ArrayInsertAt() function: > > > > Example: > > For a 1d array: > > > > > > For a 2d array: > > > > > > > > > > Problem is that 'ArrayInsertAt' will insert an element(s), but > > it will overwrite what is currently at that location. What I > > need to do is shift the rows of the Array down and insert a > > new row containing the new elements. This adds to the array > > content and retains the original content of the array. > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Inserting rows into a 2d array
> It was suggested (thanks Chris) that I could insert elements > into an array by using the ArrayInsertAt() function: > > Example: > For a 1d array: > > > For a 2d arary: > > > > > Problem is that 'ArrayInsertAt' will insert an element(s), but > it will overwrite what is currently at that location. What I > need to do is shift the rows of the Array down and insert a > new row containing the new elements. This adds to the array > content and retains the original content of the array. According to the documentation, existing elements should automatically be shifted up one in position, so you shouldn't be having this problem. What version of CF are you using? Alternatively, why not just order the data the way you want it before building the array? Or, perhaps more importantly, why does the ordering matter at all? Ideally, in most (but not all) situations, it shouldn't. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
It was suggested (thanks Chris) that I could insert elements into an array by using the ArrayInsertAt() function: Example: For a 1d array: For a 2d arary: Problem is that 'ArrayInsertAt' will insert an element(s), but it will overwrite what is currently at that location. What I need to do is shift the rows of the Array down and insert a new row containing the new elements. This adds to the array content and retains the original content of the array. Any ideas? Doug - Original Message - From: "DougF" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Sunday, November 16, 2003 8:06 PM Subject: Inserting rows into a 2d array > Hi all, > > Need some help with inserting rows into a 2d array. As an example I populate > an array with values cityName and LocationID from a query. I then need to > insert a new ROW between row 4 and row 5. In essence shifting rows 5 and > below down one row. I'd thought of appending to the array, then using > ArraySwap to move all elements down one row (need to keep elements in > order), then using ArrayInsertAt to populate the new row at row 5. This > seems like such an inefficient way. Any suggestions? > > Thanks, > Doug [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Inserting rows into a 2d array
You'll want to use ArrayInsertAt for this: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/functia7.htm - Calvin - Original Message - From: DougF To: CF-Talk Sent: Sunday, November 16, 2003 11:06 PM Subject: Inserting rows into a 2d array Hi all, Need some help with inserting rows into a 2d array. As an example I populate an array with values cityName and LocationID from a query. I then need to insert a new ROW between row 4 and row 5. In essence shifting rows 5 and below down one row. I'd thought of appending to the array, then using ArraySwap to move all elements down one row (need to keep elements in order), then using ArrayInsertAt to populate the new row at row 5. This seems like such an inefficient way. Any suggestions? Thanks, Doug [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]