General information
Category:
Coding, syntax & commands
>I need to use the STRTOFILE command to write a strint to a file. The problem I am having is the string needs to have carriage returns included within it (or I could break it up and write the string in several sections). I tried using the following code:
>
>buildstr="Error occured at "+ttoc(datetime())+chr(13)+chr(13)
>buildstr=buildstr+"Error # "+alltrim(str(xerno))+chr(13)+chr(13)
>buildstr=buildstr+"Error Message: "+alltrim(xmsg)+chr(13)+chr(13)
>buildstr=buildstr+"Program Line # "+alltrim(str(xline))
>
>strtofile(buildstr,"ERRORLOG.TXT",.f.)
>
>
>However, the resultant text file did not contain the necessary carriage returns. It just substituted strange characters for the chr(13)'s.
>
>I changed the code to read:
>
>buildstr="Error occured at "+ttoc(datetime())+chr(13)+chr(10)+chr(13)+chr(10)
>buildstr=buildstr+"Error # "+alltrim(str(xerno))+chr(13)+chr(10)+chr(13)+chr(10)
>buildstr=buildstr+"Error Message: "+alltrim(xmsg)+chr(13)+chr(10)+chr(13)+chr(10)
>buildstr=buildstr+"Program Line # "+alltrim(str(xline))
>
>strtofile(buildstr,"ERRORLOG.TXT",.f.)
>
>
>This change put in a carriage return but still the strange characters appears. I then changed to only use the chr(10)'s but that didn't work either.
>
>What am I doing wrong?
Why not use Low Level file commands and write to the file with FPUTS()?
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only