Sublime Forum

Problems with CRLF

#1

Hi there - I’m new to ColdFusion and also new here.

I’m trying to write a file direct to a browser.

Everything seems fine apart from the fact that I cannot get rid of CRLF on long fields

My code looks something like

<cfset tab = Chr(9)>
<cfset newline = Chr(13) & Chr(10)>

<cfoutput>#ProdId##tab#</cfoutput>
<cfoutput>#Description##tab#</cfoutput>
<cfoutput>#LongDescription##tab#</cfoutput>
<cfoutput>#unitPrice# GBP#tab#</cfoutput>
<cfoutput>#unitPrice1# GBP#tab#</cfoutput>
<cfoutput>#deliveryPrice# GBP#tab#</cfoutput>    
<cfoutput>#Qty##tab#</cfoutput>
<cfoutput>#newline#</cfoutput>

The line
#newline#
is there to add a CR+LF at the end of each row,
But as some fields are very long (LongDescription) I get CR+LF added as per below image

I want the first CRLF but not the second one.

Any ideas how to achieve this?

Many thanks

0 Likes

#2

I’d do it this way…

<cfoutput>
<pre>
#ProdId#	#Description#	#LongDescription#	#unitPrice# GBP	#unitPrice1# GBP	#deliveryPrice# GBP	#Qty#	

</pre>
</cfoutput>

I’m assuming your using some kind of looping over a query/data set in there to repeat the output. Put the loop start after the cfoutput, and the loop end before the /cfoutput. There’s many better ways to do this, but just getting started and not seeing everything your trying to do, this should help. If you need more CF help feel free to pm me. (CF dev since 1998).

0 Likes