How to Use SET ALTERNATE TO Instead of Low-Level I/O

Last reviewed: November 21, 1995
Article ID: Q122863
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
  • Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c, 2.6, 2.6a

SUMMARY

You can use the SET ALTERNATE TO command to create ASCII text files instead of using FoxPro's low-level file input/output (i/o) commands.

MORE INFORMATION

There is no code example in the Help file or the "FoxPro Language Reference" that shows you how to use the SET ALTERNATE TO command. This article gives a basic code example that demonstrates how to use the SET ALTERNATE TO command to create an ASCII text file.

   * BEGINNING OF CODE
   USE customer            && Open the customer database. This
                           && database can be found in the Tutorial
                           && subdirectory in the FoxPro directory.

   SET CONSOLE OFF         && Do not echo information to the screen
                           && when using question marks.

   SET ALTERNATE TO temp   && Output will be sent to file TEMP.TXT.

   SET ALTERNATE ON        && From this point on, using ? will write
                           && information to the file TEMP.TXT.

   * Write the following information to the file.
   ?'THIS IS TEST ONE.'
   ?cno
   x="THIS IS TEST TWO."
   ?x

   SET ALTERNATE OFF     && Question marks output will now output
                         && to the screen instead of the file,
                         && which is the default.

   SET ALTERNATE TO      && Closes the file.
   SET CONSOLE ON        && Turn console on to resume normal screen output
                         && echoed to the screen.

   USE                   && Close the customer database.
   MODIFY FILE TEMP.TXT  && Open the output file TEMP.TXT, so it can
                         && viewed.
   * END OF CODE

At this point, the text file contains three lines:

THIS IS TEST ONE. <some CNO number from the customer database> THIS IS TEST TWO.


Additional reference words: FoxWin FoxDos FoxMac 2.50 2.50a 2.50b 2.50c
2.60 2.60a
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral


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: November 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.