xHarbour Reference Documentation > Function Reference |
|
|
DbEval()
Evaluates a code block in a work area.
Syntax
DbEval( <bBlock> , ;
[<bForCondition>] , ;
[<bWhileCondition>], ;
[<nNextRecords>] , ;
[<nRecord>] , ;
[<lRest>] ) --> NIL
Arguments
- <bBlock>
- The parameter is a code block which is executed for every record matching
with the conditions specified with the following parameters. If no other
parameters are passed, <bBlock> is evaluated for all records.
- <bForCondition>
- This is an optional code block which must return a logical value.
<bBlock> is evaluated for all records where <bForCondition> yields .T. (true).
<bBlock> is not executed for records where <bForCondition> yields .F. (false).
This is equivalent to the FOR condition of database commands.
- <bWhileCondition>
- This is an optional code block which must return a logical value.
<bBlock> is evaluated while <bWhileCondition> yields .T. (true). DbEval()
returns immediately as soon as <bWhileCondition> yields .F. (false).
This is equivalent to the WHILE condition of database commands.
- <nNextRecords>
- An optional numeric parameter restricting the number of records to process
to <nNextRecords>, beginning with the current record.
It is equivalent to the NEXT clause of database commands.
- <nRecord>
- Only a single record is processed when the record number <nRecord> is
specified. It is equivalent to the RECORD clause of database commands.
- <lRest>
- An optional logical value that defaults to .F. (false). In this case, <bBlock>
is evaluated for all records. Specifying .T. (true) causes DbEval() to start
processing with the current record and continue until the end of file is
reached. <lRest> is equivalent to the ALL (.F.) and REST (.T.) clauses of
database commands.
Return
The return value is always NIL.
Description
The DbEval() function iterates the records in a work area and evaluates a code
block for all records matching the scope and/or condition defined with parameters
#2 to #5.
By default, DbEval() navigates the record pointer in the current work area.
Use an aliased expression to process records in a different work area.
Info
Example
// The example uses DbEval() to determine the number of deleted records
// in a database to calculate the space that could be freed with PACK.
PROCEDURE Main
LOCAL nCount := 0
USE Customer NEW
DbEval( {|| nCount++ }, ;
{|| Deleted() } )
? "File size could be reduced by", 100*nCount/Lastrec(),"percent"
CLOSE Customer
RETURN
Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe