1

I have the following code that is reading a spreadsheet in a file upload. My question is: How do i make COL_3 dynamic so the 3 is the index number of the loop? So something like:

<cfset test = test & variables.file.COL_[j][j]> 

but this doesnt work. This is what I have:

<cfset ColQty  = #ListLen(variables.file.ColumnList)#>
<cfset test = "">
  <cfloop from="1" to="#ColQty#" index="j">
      <cfset test = test & variables.file.COL_3[j]>     
  </cfloop> 

Any help appreciated. Thanks JC

2 Answers 2

4

You can access struct keys like this:

<cfset test = test & variables.file["COL_" & j][j]>

But I expect your code will behave incorrectly since you're not resetting test each time, so it will just keep appending over and over.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that works fine, thats ok I need to build a list for the test variable value.
2

I think you are looking for something like this.

<cfloop from="1" to="#ColQty#" index="j">
    <cfset test = test & variables.file["COL_" & j][j]>     
</cfloop> 

1 Comment

I now see this error when i apply your suggestion: Complex object types cannot be converted to simple values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.