Command LIST Foundation

Outputs records and/or displays them on the screen.

LIST <Expression,...> ;
   [FOR     <lForCondition>] ;
   [WHILE   <lWhileCondition>] ;
   [NEXT    <nCount>] ;
   [RECORD  <xRecordID>] ;
   [TO FILE <cFilename>] ;
   [REST] ;
   [ALL] ;
<Expression,...> is a comma-separated list of expressions to display or output for each record in the current work area.
<lForCondition> is an optional logical expression defining a condition. The expressions in the list <Expression,...> are displayed or output only when <lForCondition> returns the value .T. (true).
<lWhileCondition> is an optional logical expression defining a condition. The expressions in the list <Expression,...> are displayed starting at the current record only as long as <lWhileCondition> returns the value .T. (true). As soon as the expression results in the value .F. (false), the operation is terminated.
<nCount> optionally specifies the number of records to display starting with the current record.
<xRecordID> is an optional record ID (for DBF files it is the record number). If the record ID is included, only the specified data record is displayed.
FILE <cFilename>
<cFilename> specifies the name of the file to which the data is also written. The name must contain the drive and path if they are necessary. The file name can be specified either as a literal or as a character expression in parentheses. When the file name is specified without a file extension, ".TXT" is used by default. The file is created. If it already exists, it is overwritten without warning.
The option TO PRINTER specifies that the output should also be sent to the printer.
The option REST specifies whether records are displayed only from the current record to the last record. If a condition is specified, the option ALL is the default value.
The option ALL specifies whether all records in the work area are displayed. This is the default setting. If a condition is specified, the condition is tested for all records.
Specifying the option OFF indicates that the record ID is not output. For DBF files, the record ID is the record number (RecNo()).

The command LIST outputs the values of the expression list <Expression,...> in table form. The values are separated by blank spaces. LIST does not display column headings and processes the data records in the current work area sequentially. The expression list is output for each record matching the conditions or until the specified number of records have been output. During processing of the records, the display is not paused. LIST is identical to the command DISPLAY, except for the default number of records. For LIST, the default option is ALL (all records are output).

The command LIST outputs the values of <Expression,...> on the screen. The output can also be sent to the printer or to a file using the options TO PRINTER or TO FILE. To suppress output on the screen, the command SET CONSOLE OFF must be specified before the call of LIST.

records marked for deletion are not output when SET DELETED is turned ON. Otherwise, the deletion flag is identified in the output by an asterisk (*).

The function DbList() is the functional equivalent of LIST.

// In the example, all parts from an inventory file 
// where the inventory quantity is less than the minimum 
// inventory level are listed. This creates and prints 
// out an order list. 


   USE Inventry NEW 

   LIST PartNo, Part, OnStock, MinAmount TO PRINTER ; 
    FOR OnStock < MinAmount 

Pausing output of LIST
// The example shows how the screen display can be paused 
// after each MaxRow() rows and how the option to terminate 
// output using the ESC key can be provided. 

#include "" 

   LOCAL nCount := 0 

   USE Customer NEW 

   LIST LName, FName, Phone ; 
        WHILE IIf( ++nCount % MaxRow()==0, Inkey(0)<>K_ESC, .T. ) 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.