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

ID: Q122863

2.5x 2.60 2.60a | 2.5x 2.60 2.60a | 2.5x 2.60 2.60a

WINDOWS         | MS-DOS          | MACINTOSH

The information in this article applies to:

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: KBSubcategory: FxprgGeneral

Keywords          : kbcode FxprgGeneral 
Version           : 2.5x 2.60 2.60a | 2.5x 2.60 2.60
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: May 22, 1998