|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Trying to access these array values
Author: Will Tomlinson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56858#308280
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>
Author: Will Tomlinson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56858#308279
>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
Author: Will Tomlinson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56858#308237
>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
Author: Barney Boisvert
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56858#308236
You need to add the indexes to your output loops:
----- Excess quoted text cut - see Original Post for more -----
Author: Will Tomlinson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56858#308235
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
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||