xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

SET ALTERNATE

Records the console output in a text file.

Syntax

SET ALTERNATE TO [<fileName> [ADDITIVE]]

or

SET ALTERNATE on | OFF | ( <lOnOff> )

Arguments

TO <fileName>
This is the name of a standard ASCII text file that receives console output. The default extension for <fileName> is .TXT. The file name can be specified as a string literal or a character expression enclosed in parentheses. When the file name is specified without drive letter and path, the file is created in the current directory. An existing file with the same name is overwritten without warning.
ADDITIVE
The ADDITIVE option causes console output be appended to an existing file. Without this option, a new and empty file is created before output is written to the file.
ON | OFF | ( <lOnOff> )
This option toggles if output is written to a file. With ON or .T. (true). console output is written to the file. OFF or .F. (false) switch this mode off.

Description

The SET ALTERNATE command writes console output to an ASCII text file with the default extension .TXT. The file is created as a new file unless the ADDITIVE option is used. Output to the file starts when SET ALTERNATE ON is executed and it ends with SET ALTERNATE OFF. The latter does not close the file but stops recording output. The file can be closed with CLOSE ALTERNATE, CLOSE ALL or SET ALTERNATE TO with no argument.

Some commands which display output to the console view have a TO FILE clause. It has the same result as the SET ALTERNATE command. A full-screen command such as @...SAY can not be echoed to a file. Instead, use SET PRINTER TO <xcFile> with SET DEVICE TO PRINTER to enable this.

Note:  alternate files are not related to work areas. Therefore, only one file can be open with SET ALTERNATE at any time.

Info

See also:CLOSE, FCreate(), FOpen(), FWrite(), Set(), SET CONSOLE, SET PRINTER
Category: Console commands
Source:rtl\console.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// This example creates an alternate file and writes the results
// of the ? command to the file:

   PROCEDURE Main
      SET ALTERNATE TO MyFile
      SET ALTERNATE ON
      USE Employees NEW

      DO WHILE !EOF()
         ? Employees->Name
         SKIP
      ENDDO

      SET ALTERNATE OFF
      CLOSE ALTERNATE
      CLOSE Employees
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe