Skip to main content
Known Participant
June 29, 2011
Question

Complex object types cannot be converted to simple values?

  • June 29, 2011
  • 1 reply
  • 13037 views

Hello,

I am a newbie to coldfusion attempting to list the contents of a directory and keep getting an error that reads Complex object types cannot be converted to simple values. The error is occurring on line 11, at .<cfloop collection="#picturelist#.  Any help would be greatly appreciated!

<cfset basefolder = "\\url\Corner_Reports" >          


<cfdirectory recurse="no" action="list" directory="#basefolder#" filter="*.pdf" name="picturelist">

<cfdump var="#picturelist#">      


<cfloop collection="#picturelist# " item="thefile">       

 
  <cfset filetoread = "#picturelist.directory#\#picturelist.name#">  
 
  <cfoutput query ="corner_reports">
  Looking in: #filetoread# --                                
    <cffile action="read" file="#filetoread#" variable="filetext">
<a href="#picturelist.Directory#\#picturelist.name#index.htm" title="#picturelist.name#">
  </cfoutput>
</cfloop>

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 29, 2011

    Collection loops work on structs, not recordsets.  Use a query loop.

    Here're the relevant docs for your perusal (always a good first port of call when something ain't working):

    CFLOOP

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fe2.html

    --

    Adam

    Known Participant
    June 29, 2011

    Thanks for the advice.

    I changed my loop to a query loop and am still getting the same message about complex object types. Is there something else I am missing?

    <cfset basefolder = "
    url\g$\Images\CORNER_REPORTS\0" >

    </cfloop

    Inspiring
    June 29, 2011

    Hi

    If you want to post code, you need to do it via the web UI (http://forums.adobe.com/message/3770618#3770618).  Posting code via email dun't work.

    But you should be able to work this out for yourself.  The error will be giving you a line number, and on that line you're trying to do something like:

    <cfoutput>#aRecordSet#</cfoutput>

    There are certain operations in CF that can only be performed on simple values, whereas you're trying to do this on a complex value (record set, struct, array, etc).

    Also: if you have an error on the screen, don't DESCRIBE the error, eg: "getting the same message about complex object types".  Post the *actual error*.  I strongly doubt it's exactly the same error (same line, same code); it's just a similar one.

    Post your code again via the web UI, and we'll sort it out.

    --

    Adam