Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
STRTOFILE and Carriage Returns
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00430477
Message ID:
00430621
Views:
14
>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
Map
View

Click here to load this message in the networking platform