PRB: Unnecessary Carriage Returns in FoxPro for UNIX Files

Last reviewed: June 29, 1995
Article ID: Q132102
The information in this article applies to:
  • Microsoft FoxPro for UNIX, version 2.6

SYMPTOMS

It is possible that FoxPro for UNIX files could have both carriage return (CR) and line feed (LF) (also called newline, abbreviated NL) characters in them. An editing program like vi would display the CR-LF pair as a control M (^M). This CR character may cause problems when printing or doing other operations.

CAUSE

One way to end up with unnecessary CR characters is to use functions that produce CR-NL pairs. For example, rather than using FPUTS(), use FWRITE() to write the string to a file, and then use an FWRITE() of CHR(10) to produce the UNIX-style NL character.

RESOLUTION

If the file already has the CR characters in it:

  1. Create a shell script through vi or another editor called 'xcr' for example.

  2. The UNIX shell script should contain the following line:

    tr -d "\015"

  3. Use the following command at the UNIX prompt to make the file executable:

    chmod 777 xcr

  4. To clear CR characters from a file called myfile and put the new file in mynewfile, use this command:

    xcr < myfile > mynewfile

NOTE: The '<' character means for the program xcr to accept input from the file called myfile. Accordingly, the '>' character before mynewfile means to take the output produced from running xcr on myfile and put it into a new file called mynewfile. For more information on file rediretion, consult your UNIX documentation.


Additional reference words: FoxUnix 2.60
KBCategory: kbinterop kbprb
KBSubcategory: FxinteropGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.