Using StringBuffer With CFFILE

Good morning!

This is not a critical issue - I have the function working using CFFILE’s
append method. I’m mainly interested in learning the right way to do this
sort of thing for the future.

When I was Googling information on using CFFILE, I came across a 2007 blog
entry from Ben Nadel that showed a more efficient way to build the CSV and
I wanted to try it out.

When I attempt to use a stringBuffer created object (tostring) as the
CFFILE output, Lucee returns “Can’t cast Complex Object Type Query to
String, Use Built-In-Function “serialize(Query):String” to create a String
from Query”

It returns this message even when using serialize.

The object works as expected when dumping or writing to cfoutput.

My environment is:

Test server running Lucee 4.5.1.023 on Windows Server 2012 R2, IIS 8
Production server running Lucee 4.5.1.022 on Debian (Hostmedia.co.uk VPS)

Also, I have AFC 10 and 11, both running on Server 2012 R2, at the day job
and usually cross-test there.

I’ve attached two files.

  1. sbuffer.cfm is from my AFC servers and shows that the basic
    functionality works there - I know that compatability varies by function,
    just showing how it works.

  2. javapickSchool.cfm is from Lucee. I’ve included a copy of the query
    functions I call from the CFC, a few remarks about what the code is doing,
    and I’ve also commented out variations that did not work.

Please keep in mind that I’m an experienced tester but a novice programmer,
so if I’m doing something stupid, you’ll help me a lot by pointing it out.

Also, let me know if you need any more information!

Thanks, Micha!

I will use your recommendation.

To answer your request - the code that doesn’t work is in the attachment
named "javapickSchool.cfm"On Thursday, September 3, 2015 at 8:01:30 AM UTC-4, Doug Roberson wrote:

Good morning!

This is not a critical issue - I have the function working using CFFILE’s
append method. I’m mainly interested in learning the right way to do this
sort of thing for the future.

When I was Googling information on using CFFILE, I came across a 2007 blog
entry from Ben Nadel that showed a more efficient way to build the CSV and
I wanted to try it out.

ColdFusion Optimizing Case Study: Writing Orders To A CSV File

When I attempt to use a stringBuffer created object (tostring) as the
CFFILE output, Lucee returns “Can’t cast Complex Object Type Query to
String, Use Built-In-Function “serialize(Query):String” to create a String
from Query”

It returns this message even when using serialize.

The object works as expected when dumping or writing to cfoutput.

My environment is:

Test server running Lucee 4.5.1.023 on Windows Server 2012 R2, IIS 8
Production server running Lucee 4.5.1.022 on Debian (Hostmedia.co.uk VPS)

Also, I have AFC 10 and 11, both running on Server 2012 R2, at the day job
and usually cross-test there.

I’ve attached two files.

  1. sbuffer.cfm is from my AFC servers and shows that the basic
    functionality works there - I know that compatability varies by function,
    just showing how it works.

  2. javapickSchool.cfm is from Lucee. I’ve included a copy of the query
    functions I call from the CFC, a few remarks about what the code is doing,
    and I’ve also commented out variations that did not work.

Please keep in mind that I’m an experienced tester but a novice
programmer, so if I’m doing something stupid, you’ll help me a lot by
pointing it out.

Also, let me know if you need any more information!

Can you show me the code you are running, the exception is about a query
that cannot be translated to a string. So something else seems off.

Hi Doug

i have reviewed your code and i think i have found the problem, i cannot
execute the code because i miss the enviroment so i’m not a 100% sure, but
99% ;-).
The exception says that the failure is happening on line 66, what would be
this line:

you assumed that “swapNames” is the problem (assumptions can be our biggest
enemy :wink: ), but in my opinion the problem is
“getExportSchoolName” so the value for the attribute “file” what need to be
a string (as the exception indicate).
on line 21 you do this:

so “getExportSchoolName” is for sure not a string, as the exception
indicates it could be a query.
should the value for the attribute “file” be “exportFileName”?

hope this helps
MichaOn Thu, Sep 3, 2015 at 9:28 PM, Doug Roberson <@Doug_Roberson1> wrote:

Thanks, Micha!

I will use your recommendation.

To answer your request - the code that doesn’t work is in the attachment
named “javapickSchool.cfm”

On Thursday, September 3, 2015 at 8:01:30 AM UTC-4, Doug Roberson wrote:

Good morning!

This is not a critical issue - I have the function working using CFFILE’s
append method. I’m mainly interested in learning the right way to do this
sort of thing for the future.

When I was Googling information on using CFFILE, I came across a 2007
blog entry from Ben Nadel that showed a more efficient way to build the CSV
and I wanted to try it out.

ColdFusion Optimizing Case Study: Writing Orders To A CSV File

When I attempt to use a stringBuffer created object (tostring) as the
CFFILE output, Lucee returns “Can’t cast Complex Object Type Query to
String, Use Built-In-Function “serialize(Query):String” to create a String
from Query”

It returns this message even when using serialize.

The object works as expected when dumping or writing to cfoutput.

My environment is:

Test server running Lucee 4.5.1.023 on Windows Server 2012 R2, IIS 8
Production server running Lucee 4.5.1.022 on Debian (Hostmedia.co.uk VPS)

Also, I have AFC 10 and 11, both running on Server 2012 R2, at the day
job and usually cross-test there.

I’ve attached two files.

  1. sbuffer.cfm is from my AFC servers and shows that the basic
    functionality works there - I know that compatability varies by function,
    just showing how it works.

  2. javapickSchool.cfm is from Lucee. I’ve included a copy of the query
    functions I call from the CFC, a few remarks about what the code is doing,
    and I’ve also commented out variations that did not work.

Please keep in mind that I’m an experienced tester but a novice
programmer, so if I’m doing something stupid, you’ll help me a lot by
pointing it out.

Also, let me know if you need any more information!


See Lucee at CFCamp Oct 22 & 23 2015 @ Munich Airport, Germany - Get your
ticket NOW - http://www.cfcamp.org/


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/f53b68e0-ce04-49dc-97ed-b3d82a055f95%40googlegroups.com
https://groups.google.com/d/msgid/lucee/f53b68e0-ce04-49dc-97ed-b3d82a055f95%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

You, sir, are a wizard, making fire for cavemen, and I thank you.

I was totally fixated on the output and never considered that the problem
could be file path or name.

Thank you!On Thursday, September 3, 2015 at 8:01:30 AM UTC-4, Doug Roberson wrote:

Good morning!

This is not a critical issue - I have the function working using CFFILE’s
append method. I’m mainly interested in learning the right way to do this
sort of thing for the future.

When I was Googling information on using CFFILE, I came across a 2007 blog
entry from Ben Nadel that showed a more efficient way to build the CSV and
I wanted to try it out.

ColdFusion Optimizing Case Study: Writing Orders To A CSV File

When I attempt to use a stringBuffer created object (tostring) as the
CFFILE output, Lucee returns “Can’t cast Complex Object Type Query to
String, Use Built-In-Function “serialize(Query):String” to create a String
from Query”

It returns this message even when using serialize.

The object works as expected when dumping or writing to cfoutput.

My environment is:

Test server running Lucee 4.5.1.023 on Windows Server 2012 R2, IIS 8
Production server running Lucee 4.5.1.022 on Debian (Hostmedia.co.uk VPS)

Also, I have AFC 10 and 11, both running on Server 2012 R2, at the day job
and usually cross-test there.

I’ve attached two files.

  1. sbuffer.cfm is from my AFC servers and shows that the basic
    functionality works there - I know that compatability varies by function,
    just showing how it works.

  2. javapickSchool.cfm is from Lucee. I’ve included a copy of the query
    functions I call from the CFC, a few remarks about what the code is doing,
    and I’ve also commented out variations that did not work.

Please keep in mind that I’m an experienced tester but a novice
programmer, so if I’m doing something stupid, you’ll help me a lot by
pointing it out.

Also, let me know if you need any more information!