PRB: How to Remove ^M (CHR(13)) from FoxPro UNIX Text FileLast reviewed: January 15, 1996Article ID: Q142285 |
The information in this article applies to:
SYMPTOMSFoxpro for UNIX places a carriage return/line feed pair ( 0D 0A in hex ) at the end of lines in text files that were created by commands such as REPORT FORM xxxx TO FILE yyyy in addition to any printer codes that might be appropriate (if _PDSETUP contains a valid printer driver name). Not all UNIX programs are designed to accommodate the carriage return character.
CAUSEFoxpro expects the carriage return/line feed pair to be a proper line termination indicator and thus places it at the end of lines in text files it creates.
WORKAROUNDA program, such as the example below, may be used to read the text file after it is created by Foxpro and then output a new file, devoid of the ^M (CHR(13)) terminator for use by other UNIX programs. * begin strip13.prg * Created to strip the ^M's (chr(13)) out of .TXT files that are * routinely added by Foxpro at the end of each line. PARAMETER out_fname IF .NOT. FILE(out_fname) WAIT WINDOW 'INPUT FILE ' + out_fname + ' does not exist'ELSE in_fname='input.txt' && name to change original file to IF FILE(in_fname) && during the 'stripping' process DELETE FILE &in_fname ENDIF RENAME &out_fname TO &in_fname in_fh = FOPEN(in_fname) && Input File Handle ifp_size=FSEEK(in_fh,0,2) ifp_top=FSEEK(in_fh,0) IF ifp_size <= 0 WAIT WINDOW 'Your INPUT File Is Empty!!' ELSE IF FILE(out_fname) DELETE FILE out_fname && just in case ENDIF out_fh=FCREATE(out_fname) && Output File Handle DO WHILE .NOT. FEOF(in_fh) in_text = FGETS(in_fh) IF LEN(in_text)>0 && If blank line, don't write =FWRITE(out_fh,in_text+CHR(10)) ENDIF ENDDO ENDIF =FCLOSE(in_fh) =FCLOSE(out_fh)ENDIF * End of Strip13.prg
STATUSThis behavior is by design. FoxPro expects the carriage return/line feed pair to be a proper line termination indicator and thus places it at the end of lines in text files it creates.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional reference words: 2.60 FoxUnix
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |