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!

Need to fputs a carriage return line feed in the log file 1

Status
Not open for further replies.

traderbob

IS-IT--Management
Apr 15, 2001
11
0
0
US
Please help
I'm using the following text to write to a logfile the date and time the script started:
String Fname = "Logfile.txt" ;String to set logfile name
; Open the logfile for write

if fopen 0 Fname APPEND

;Write the current date and time into the log file
fputs 0 "Studio Automation Macro initiated on "
fputs 0 $DATE
fputs 0 " & "
fputs 0 $TIME
fputs 0 "^M"
fclose 0

endif

At the end of the script.... the ^M is putting a ^M in the logfile instead of putting in a carriage return. If I don't put the ^M in quotes, the script won't compile. Any idea what I should fputs into the file to start a new line so all the log entries are not put together. I do want them all in the same log file, just not all on the same line.
Thanks,
b.l.
 
I believe this might do the trick.

Code:
string sText
if fopen 0 Fname APPEND TEXT

;Write the current date and time into the log file   
   sText = "Studio Automation Macro initiated on "
   strcat sText $DATE
   strcat sText " & "
   strcat sText $TIME
   fputs 0 sText
   fclose 0
endif

There are probably more effecient ways to do this. I don't think "^M" transmitted to a terminal is the same as a carriage return in a text file.
 
You will need to replace the ^M with `n and possibly also `r (the first is a carriage return, the second is a linefeed) to get the formatting you desire.

 
See, told you there was a better way!
 
Knob, thanks for your post... I was just struggling with this same thing when I thought I'd check here and whaddaya know? there's a post with the exact problem I'm dealing with. And I didn't even have to SEARCH for it!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top