|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Trying to access these array values
I have a multi dimensioned array. I had no problem creating it, and I can dump it. But now it's time to spit out all the values formatted nicely. I've been havin a hard time gettin this right.Will Tomlinson 06/27/08 11:56 A You need to add the indexes to your output loops:Barney Boisvert 06/27/08 12:00 P >You need to add the indexes to your output loops:Will Tomlinson 06/27/08 12:08 P >You need to add the indexes to your output loops:Will Tomlinson 06/28/08 07:16 P I got it. It's kinda funkadelic.Will Tomlinson 06/28/08 09:13 P I have a multi dimensioned array. I had no problem creating it, and I can dump it. But now it's time to spit out all the values formatted nicely. I've been havin a hard time gettin this right. Here's how I generated it: <cfoutput query="getchecks"> <!--- Check this line with a RegEx ---> <cfif reFindNoCase(getchecks.cr_regextouse, thisLine)> <cfset lineNum = lineNum + 1> <cfset errorArray[lineNum] = arrayNew(1)> <cfset errorArray[lineNum][1] = arrayNew(1)> <cfset errorArray[lineNum][1][1] = arrayNew(1)> <cfset errorArray[lineNum][1][1][1] = arrayNew(1)> <cfset errorArray[lineNum][1][1][1][1] = arrayNew(1)> <cfset errorArray[lineNum][1][1][1][1][1] = arrayNew(1)> <cfset errorArray[lineNum][1][1][1][1][1] = getchecks.cr_errortitle> <cfset errorArray[lineNum][1][1][1][1][2] = "Line ##" & sourceLineNum> <cfset errorArray[lineNum][1][1][1][1][3] = "Source text" & thisLine> <cfset errorArray[lineNum][1][1][1][1][4] = "Dir" & mySite.directory & "\" & mySite.name> <cfset errorArray[lineNum][1][1][1][1][5] = getchecks.cr_suggestion> </cfif> </cfoutput> </cfif> HEre's how I'm trying to output it: <cfoutput> <cfloop from='1' to='#lineNum#' index='i'> <cfloop from='1' to='#arrayLen(errorArray)#' index='j'> <cfloop from='1' to='#arrayLen(errorArray)#' index='k'> <cfloop from='1' to='#arrayLen(errorArray)#' index='l'> <cfloop from='1' to='#arrayLen(errorArray)#' index='m'> <cfloop from='1' to='#arrayLen(errorArray)#' index='n'> #errorArray[i][1][1][1][1][n]# </cfloop> </cfloop> </cfloop> </cfloop> </cfloop> </cfloop> </cfoutput> I'm getting the same values multiple times. Thanks, Will You need to add the indexes to your output loops: ----- Excess quoted text cut - see Original Post for more ----- >You need to add the indexes to your output loops: > > > Perfect as usual Barney! I was beating my head against the wall trying to make it work for the last 30 mins (ok maybe an hour, so what...). Thank you! Will >You need to add the indexes to your output loops: > Barney, I did ok appending a text file with the columns of values of the innermost array, but I'm havin a hard time convert it to a query row. I'm gettin a column count doesnt match error. <cfquery datasource="#dsn#"> insert into tbllog (log_name, log_time, log_problem, log_linenum, log_sourcetext, log_directoryfile, log_suggestion) values( <!--- <cffile action="append" file="#form.logPath#" addnewline="yes" output=" Scan Performed: #DateFormat(now(), "m/dd/yyyy")# #TimeFormat(now(), "h:mm tt")# Page: #name# "> ---> <cfloop from='1' to='#lineNum#' index='i'> <cfloop from='1' to='#arrayLen(errorArray[i])#' index='j'> <!--- <cffile action="append" file="#form.logPath#" addnewline="yes" output="******************************************************************************************************"> ---> <cfloop from='1' to='#arrayLen(errorArray[i][j])#' index='k'> <cfloop from='1' to='#arrayLen(errorArray[i][j][k])#' index='l'> <cfloop from='1' to='#arrayLen(errorArray[i][j][k][l])#' index='m'> <cfloop from='1' to='#arrayLen(errorArray[i][j][k][l][m])#' index='n'> <cfset nCtr = nCtr + 1> <cfloop from="1" to="#arrayLen(errorArray[i][j][k][l][m][n])#" index="thisItem"> <cfif len(errorArray[i][j][k][l][m][n])> <cfif not isNumeric(errorArray[i][j][k][l][m][n])> <cfqueryparam value="#errorArray[i][j][k][l][m][n]#"> <cfelse> <cfqueryparam cfsqltype="cf_sql_integer" value="#errorArray[i][j][k][l][m][n]#"> </cfif> <cfelse> NULL </cfif> <cfif not nCtr eq 5> , </cfif> </cfloop> <!--- <cffile action="append" file="#form.logPath#" addnewline="yes" output="#errorArray[i][j][k][l][m][n]#"> ---> </cfloop> </cfloop> </cfloop> </cfloop> </cfloop> </cfloop> ) </cfquery> Thanks much, Will I got it. It's kinda funkadelic. <cfloop from='1' to='#lineNum#' index='i'> <cfquery datasource="#dsn#"> insert into tbllog (log_name, log_time, log_problem, log_linenum, log_sourcetext, log_directoryfile, log_suggestion) values( '#form.scanname#' , <cfqueryparam cfsqltype="cf_sql_timestamp" value="#createODBCDateTime(now())#"> , <cfloop from='1' to='#arrayLen(errorArray[i])#' index='j'> <cfset nCtr = nCtr + 1> <!--- <cffile action="append" file="#form.logPath#" addnewline="yes" output="******************************************************************************************************"> ---> <cfloop from='1' to='#arrayLen(errorArray[i][j])#' index='k'> <cfloop from='1' to='#arrayLen(errorArray[i][j][k])#' index='l'> <cfloop from='1' to='#arrayLen(errorArray[i][j][k][l])#' index='m'> <cfloop from='1' to='#arrayLen(errorArray[i][j][k][l][m])#' index='n'> <cfif len(errorArray[i][j][k][l][m][n])> <cfif n eq 2> <cfqueryparam cfsqltype="cf_sql_integer" value="#errorArray[i][j][k][l][m][n]#"> <cfelse> <cfqueryparam cfsqltype="cf_sql_varchar" value="#errorArray[i][j][k][l][m][n]#"> </cfif> <cfelse> NULL </cfif> <cfif n neq arrayLen(errorArray[i][j][k][l][m])> , </cfif> <!--- <cffile action="append" file="#form.logPath#" addnewline="yes" output="#errorArray[i][j][k][l][m][n]#"> ---> </cfloop> </cfloop> </cfloop> </cfloop> </cfloop> ) </cfquery> </cfloop>
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||