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

Remove the last chr(13) & chr(10) from a string

LEGEND ,
Jul 06, 2009 Jul 06, 2009

Copy link to clipboard

Copied

Hello, all.

I'm trying to get confirmation files to upload to Amazon for their "Charge When Ship" program.  I've got the file creating as it should be with one minor exception.

I'm setting a variable, giving it the header column information and ending that with chr(13) & chr(10); then I'm looping through a query to add the information, each iteration tacks chr(13) & chr(10) to the end of it; then I'm taking that variable and writing the data to a file using CFFILE.

But I think that the last chr(13) & chr(10) is causing Amazon servers to think there's one more line of information than there really is, and it's erroring.

Can anyone tell me how to remove that last chr(13) & chr(10) from the variable before writing it to file?

Thanks,

^_^

Views

2.2K

Translate

Translate

Report

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

correct answers 1 Correct answer

Valorous Hero , Jul 06, 2009 Jul 06, 2009

giving it the header column information and ending that with chr(13) & chr(10); then I'm looping through a query to add the information, each iteration tacks chr(13) & chr(10) to the end of it; then I'm taking that variable and writing the data to a file using CFFILE.

Trim() the variable or change the code so it does not generate an extra new line.

Since your content has a header, place the new line characters at the beginining of each query iteration.

#headerColumnsHere#  <!--- notice there is no

...

Votes

Translate

Translate
Valorous Hero ,
Jul 06, 2009 Jul 06, 2009

Copy link to clipboard

Copied

giving it the header column information and ending that with chr(13) & chr(10); then I'm looping through a query to add the information, each iteration tacks chr(13) & chr(10) to the end of it; then I'm taking that variable and writing the data to a file using CFFILE.

Trim() the variable or change the code so it does not generate an extra new line.

Since your content has a header, place the new line characters at the beginining of each query iteration.

#headerColumnsHere#  <!--- notice there is no new line after the column header  information --->

<cfouput query="yourQuery">#chr(13)##chr(10)# #ColumnA##ColumnB#...etcetera...</cfoutput>

Votes

Translate

Translate

Report

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
LEGEND ,
Jul 07, 2009 Jul 07, 2009

Copy link to clipboard

Copied

LATEST

Using trim() did not remove the last line break from the string (nor did I expect it to; it really just removes spaces.)

However, when I read your suggestion to place the line breaks at the beginning of the output lines, I almost knocked myself unconscious smacking myself in the forehead.  I was looking for a complex solution, I didn't see the simple one that was right in front of me.  Thanks for pointing this out, to me.  I really appreciate the solid thinking behind that one.

^_^

Votes

Translate

Translate

Report

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
Documentation