Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to give carriage return in a text file

Status
Not open for further replies.

VikramChand

Programmer
Jul 5, 2002
16
0
0
US
Hi,

I have written the following code for the carriage return . Can u let me know what is wrong with this. I am not able to get the carriage return sequence after every line is wrtten to the test file.

My code

fopen 10 "c:\test\Log.txt" readappend
strfmt tempstr "TRNSFR|1|0|%-s|%-s|%-s|%-s|%-s" $DATE $TIME $SCRIPTFILE ftobeuploaded filereference
fputs 10 tempstr
fwrite 0 0x0A0D
fclose 10

thanks
 
You can use this:

fputs 10 "`r"

If you also want to add a linefeed (since you reference 0x0A), you could use:

fputs 10 "`r`n"

instead. Another option is using the TEXT argument in your fopen command, which would cause all file writes via fputs to add the carriage return and line feed automatically.
aspect@aspectscripting.com
 
Thanx for immediate response KNOB. U r the best.

But i figured out the way and fixed the code just after i posted the request.

The bug was

insted of this "fwrite 0 0x0A0D"
i have to write "fwrite 10 0x0A0D"

the file ID i was opening the file is different from the one i was writing.

Any way thanks once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top