Function DbList() Foundation

Displays records from a work area.

Syntax
DbList( [<aCodeblocks>], ;
        [<lNoRecno>], ;
        [<lAll>], ;
        [<bForCondition>], ;
        [<bWhileCondition>], ;
        [<nCount>], ;
        [<xRecordID>], ;
        [<lRest>], ;
        [<lPrint>], ;
        [<cFilename>] ) --> NIL
Parameters
<aCodeblocks>
<aCodeblocks> is an optional array of code blocks. Each code block in the array is evaluated for each record. The return value of each code block is displayed. If no array is specified, the function lists all fields.
<lNoRecno>
<lNoRecno> is an optional logical value which indicates whether the record number is displayed. The default is .F. (false), meaning the record number is displayed.
<lAll>
<lAll> is a logical value specifying whether the code blocks in <aCodeblocks> are to be evaluated for all records. The default value is .T. (true). If the value .F. (false) is specified, the code blocks in the array are evaluated only for the current record, unless <nCount> is specified. If <nCount> is specified, the code blocks are evaluated for <nCount> records.
<bForCondition>
<bForCondition> is an optional code block containing a condition as a logical expression. The code blocks in <aCodeblocks> are only evaluated for those records where <bForCondition> returns the value .T. (true).
<bWhileCondition>
<bWhileCondition> is an optional code block containing a condition as a logical expression. As long as this code block returns the value .T. (true), the code blocks in<aCodeblocks> are evaluated. The operation is terminated as soon as <bWhileCondition> provides the value .F.(false).
<nCount>
<nCount> optionally specifies the number of records for which the code blocks in <aCodeblocks> are evaluated.
<xRecordID>
<xRecordID> is an optional record ID (for DBF files it is the record number). If it is specified, the code blocks in <aCodeblocks> are evaluated beginning with this record.
<lRest>
The logical value <lRest> optionally specifies whether the code blocks in <aCodeblocks> are evaluated for all records in a work area (<lRest>==.F.), or only from the current to the last data record (<lRest>==.T.). The default value is .F. (false).
<lPrint>
If the value .T. (true) is specified for <lPrint>, the output of the return values of the code blocks is also sent to the printer. The default value is .F. (false), meaning that the return values are only displayed on the screen.
<cFilename>
<cFilename> is a character string containing the name of the file where the printer output is sent. For this to work, <lPrint> must contain the value .T. (true). A new file is created. If a file by this name already exists, it is overwritten without warning.
Return

The return value of DbList() is always NIL.

Description

The function DbList() provides a simple way to display a table of data from a work area. The data display is specified to the function in the form of an array containing code blocks in each element. The code blocks are evaluated for each record and the return values are displayed on the screen. Output to a printer or file can also be specified. In order to suppress the screen display, screen output must be turned off using SET CONSOLE OFF before the call to DbList().

The number of records for which the code blocks are evaluated can be limited by additional parameters. If DbList() is called without parameters, the function displays all fields of all records in the current work area on the screen. An asterisk * is displayed at the beginning of the line for each record marked as deleted, as long as SET DELETED is turned OFF.

DbList() is used for the implementation of the two commands DISPLAY and LIST.

Examples
DbList()
// The example lists all items from a 'supply on hand' inventory 
// file where the count in the supply is less than the minimum 
// inventory level. The output is sent to a file listing 
// reorders. 
PROCEDURE Main 
   LOCAL aArray 
   DbUseArea( .T.,,"Supply" ) 

   aArray := { ; 
      {|| FIELD->ItemNo   } , ; 
      {|| FIELD->Item     } , ; 
      {|| FIELD->Count    } , ; 
      {|| FIELD->MinLevel }   ; 
   } 

   DbList( aArray, .T., .T., ; 
           {|| FIELD->InStock < FIELD->MinInventory },,,,,; 
           .T., "Order.txt" ) 
   DbCloseArea() 
RETURN 
Feedback

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.