Given that listgetat is slow at retrieving values, I would suggest it may be quicker to use ArrayToList and then use array[i] as the method for retrieving the info...
Performance loss on arraytolist and using [] notation is probably less than the performance loss on using listgetat a number of times! Paul > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Sent: 07 July 2003 11:22 > To: [EMAIL PROTECTED] > Subject: [ cf-dev ] list loop backwards > > > What's the best way to loop backwards through a list? i'm > reading in a text file, and turning each line into a list > item. got a line that contains a value like Surname123, and > I know I need to find Name123 which is a few list items up in > the list (could be a variable amount of lines apart). There > doesn't seem to be a built-in function (CF 4.5) to loop > backwards over the list starting at a given item. I was > thinking perhaps something like: > > <cfset lineNumber1 = ListGetAt(fileList, 'Surname123', > '#Chr(10)##Chr(13) #')> > <!--- what line number is our start line on? ---> > > <cfloop index="i" from=lineNumber1 to="1" step="-1"> > <!--- loop all the way back to the start if need be ---> > <cfif FindNoCase("Name123", ListGetAt(fileList, i, > "#Chr(10)##Chr(13) #")> > <!--- found the value we're looking for in this line ---> > <cfset Name = ListGetAt(fileList, i, "#Chr(10)##Chr(13)#")> > <!--- assign to a variable ---> > <cfbreak><!--- break out of the loop ---> > </cfif> > </cfloop> > > It just seems like there has to be a simpler way of doing this? > > > Duncan Cumming > IT Manager > http://www.alienationdesign.co.uk mailto:[EMAIL PROTECTED] Tel: 0141 575 9700 Fax: 0141 575 9600 Creative solutions in a technical world ---------------------------------------------------------------------- Get your domain names online from: http://www.alienationdomains.co.uk Reseller options available! ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
