Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

array append error "Object of type class java.lang.String cannot be used as an array"

Participant ,
Apr 22, 2009 Apr 22, 2009

I have an array that I would like to continue adding items to. Setting the array and displaying the contents works fine but when I try to append I get the error message "Object of type class java.lang.String cannot be used as an array"  Should this be a structure? or do I have my looping in the wrong place?  The goal is to combine 200 arrays into the content variable so I can write a .csv file to the server. 

Here's the basics:

<cfset content= ArrayNew(1)>

run queries

<cfset content = "#q14.name#" &","& "#big[1]#" & "," & "#big[2]#" & chr(10)> 

(this part above displays correctly in a cfdump with the items from the query which looks like this

Category, Written communication, 10)

<cfloop index="k" from="1" to="5">

<cfset temp = arrayappend(content, "#q14.name# ,#big[1]#, #big[2]#" & chr(10))>

</cfloop>

I've also tried something as simple as <cfset ArrayAppend(content, "hello test")> which still gives the above error message.

TOPICS
Getting started
4.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 22, 2009 Apr 22, 2009

Here's the basics:

<cfset content= ArrayNew(1)>

This line create a one diminsional array named 'content'

<cfset content = "#q14.name#" &","& "#big[1]#" & "," & "#big[2]#" & chr(10)> 

This line overrides the array varaibale named 'content' with a string value converting it into a string variable.

<cfset temp = arrayappend(content, "#q14.name# ,#big[1]#, #big[2]#" & chr(10))>

This line tries to append an array element to the now converted string variable named 'content'

Message was edited by: Ian Skinner String Variable NOT String Array

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2009 Apr 30, 2009
LATEST

Why not keep it as simple as

<cfloop index="k" from="1" to="5">
<cfset content = q14.name & "," & big[1] & "," & big[2] & chr(10)>
</cfloop>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources